[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double
From: |
Stefan Monnier |
Subject: |
bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3' |
Date: |
Thu, 13 Jan 2011 12:32:40 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
> It's cleaner to let the calling Elisp code worry about this. That is to
> say, the caller can bind the first click to a command that starts up a
> timer to execute the "single click" action after a short period, and
> bind the double click to a command that cancels that timer.
Admittedly, this is pretty delicate to do right:
- if nothing happens during those 500ms, run the timer. O, that's the
easy case.
- if a second clicks comes in before those 500ms cancel the timer.
First difficulty: where do you put the code that cancels the timer?
- if another event like a click on another mouse button, or a keyboard
key comes in before the 500ms, we should be careful to run the click
command immediately (i.e. neither let the timer finish,
not just cancel it outright). And don't wait for this second event to
complete to a key-sequence bound to a command (i.e. run the click
command as soon as a C-x comes in, for example).
- but if that second event is a mouse-movement, we should not do anything.
I think the best place to put such code is somewhere around
function-key-map. Just like down-mouse-N can be dropped and
double-mouse-N can be demoted to just mouse-N, we could turn mouse-N
events that aren't bound to new single-mouse-N events. I guess we could
do it with code along the lines of:
[Check that there's no mouse-N binding, but there is a single-mouse-N
binding in the active key maps]
(let ((event
(catch 'timeout
(let ((timer
(run-with-timer 0.5 nil
(lambda () (throw 'timeout 'timeout)))))
(unwind-protect
(let (event)
(while (progn
(setq event (read-event))
(not (memq event '(mouse-movement))))) ; Any other?
event)
(cancel timer))))))
(cond
((eq event 'timeout) [single-mouse-N])
((eq event 'down-mouse-N)
(push event unread-command-events)
[])
(t
(push event unread-command-events)
[single-mouse-N])))
-- Stefan
- bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3', (continued)
- bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3', Drew Adams, 2011/01/07
- bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3', Stefan Monnier, 2011/01/08
- bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3', Drew Adams, 2011/01/08
- bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3', Jason Rumney, 2011/01/08
- bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3', Drew Adams, 2011/01/08
- bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3', Jason Rumney, 2011/01/08
- bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3', Drew Adams, 2011/01/09
- bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3', Chong Yidong, 2011/01/13
- bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3', Drew Adams, 2011/01/13
- bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3', Chong Yidong, 2011/01/14
- bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3',
Stefan Monnier <=
bug#7802: bug #7802: 24.0.50; Extraneous `mouse-3' event when do `double-mouse-3', grischka, 2011/01/08