[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Elisp test for whether `mouse-1' is pressed?

From: Drew Adams
Subject: RE: Elisp test for whether `mouse-1' is pressed?
Date: Fri, 5 Nov 2021 17:10:07 +0000

Does no one have an idea about this?  I'd really like
to know how to detect the state of `mouse-1' being
pressed (not yet released).


> What's a good way to test whether mouse-1 is
> currently pressed (which I think is still the same
> as asking to test whether we're in `mouse-drag-track')?

Seems like this would be useful for Emacs generally,
no?  In any case it will be useful to me.

We have `use-region-p', but that takes no account
of whether `mouse-1' is pressed.  So `use-region-p'
returns TRUE for a `mouse-1' press (until the button
is released).  Any user-visible action (e.g. a UI
change done by code when `use-region-p' is TRUE)
can be manifested for the duration of the press.

In my use case, a user will have chosen to use the
region even when empty (where "use" it means show
an UI indication that it's active).  This choice
can be helpful for knowing that you will be acting
on an empty region (which you might not really want
to do).

But with this `mouse-1'-press "feature", a user
sees the active-region indication (momentarily)
even for a `mouse-1' click, which is only a bother
and not a proper indication that the empty region
will be active and acted on (because releasing the
mouse button deactivates the empty region).

This test was possible in Emacs 24 via a dumb hack,
but that hack's not usable in Emacs 25+.  Besides,
I'd prefer a clean, well-lighted place (solution).

Any ideas?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]