* customizing double click
@ 2005-08-13 0:11 Rajneesh Hegde
2005-08-13 11:11 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Rajneesh Hegde @ 2005-08-13 0:11 UTC (permalink / raw)
hi,
In LaTeX mode (AUCTeX), I want double-click to have the usual
selection effect when the click is on a word-constituent character,
but otherwise do a forward-search (i.e. invoke the dvi viewer). I
wrote the following function for doing the latter:
(defun my-LaTeX-forward-search (event)
"Set point to the position of the mouse pointer and then call the
function TeX-view from AucTeX."
(interactive "e")
(if (and (numberp (posn-point (event-start event)))
(looking-at "\\W"))
(TeX-view)))
Then I bind as follows:
(define-key LaTeX-mode-map [double-down-mouse-1] 'my-LaTeX-forward-search)
The problem is that on double-clicking on a word-constituent
character, the double-down event runs the above function (which, as
expected, does nothing) , but the subsequent double-click event
doesn't have the usual effect of selecting the word.
On the other hand, if I bind my function to [double-mouse-1], it
doesn't even get invoked, although the binding is successful. What am
I missing? Thanks,
Rajneesh.
P.S. I'm using GNU Emacs 22.0.50.2 (i386-mingw-nt5.1.2600) (from
crasseux.com) on a WinXP Home machine (the mouse is a Synaptics
touchpad.) The same problem happens with precompiled Emacs 21.3.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: customizing double click
2005-08-13 0:11 customizing double click Rajneesh Hegde
@ 2005-08-13 11:11 ` Eli Zaretskii
2005-08-13 13:18 ` Rajneesh Hegde
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2005-08-13 11:11 UTC (permalink / raw)
> Date: Fri, 12 Aug 2005 20:11:32 -0400
> From: Rajneesh Hegde <emsink1@gmail.com>
>
> Then I bind as follows:
> (define-key LaTeX-mode-map [double-down-mouse-1] 'my-LaTeX-forward-search)
>
> The problem is that on double-clicking on a word-constituent
> character, the double-down event runs the above function (which, as
> expected, does nothing) , but the subsequent double-click event
> doesn't have the usual effect of selecting the word.
>
> On the other hand, if I bind my function to [double-mouse-1], it
> doesn't even get invoked, although the binding is successful. What am
> I missing? Thanks,
Does the following excerpt from the ELisp manual help you understand
the issue?
Before the double-click or double-drag event, Emacs generates a
"double-down" event when the user presses the button down for the
second time. Its event type contains `double-down' instead of just
`down'. If a double-down event has no binding, Emacs looks for an
alternate binding as if the event were an ordinary button-down event.
If it finds no binding that way either, the double-down event is
ignored.
To summarize, when you click a button and then press it again right
away, Emacs generates a down event and a click event for the first
click, a double-down event when you press the button again, and finally
either a double-click or a double-drag event.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: customizing double click
2005-08-13 11:11 ` Eli Zaretskii
@ 2005-08-13 13:18 ` Rajneesh Hegde
2005-08-15 3:52 ` Rajneesh Hegde
0 siblings, 1 reply; 4+ messages in thread
From: Rajneesh Hegde @ 2005-08-13 13:18 UTC (permalink / raw)
> Does the following excerpt from the ELisp manual help you understand
> the issue?
yeah, I think I understand that part, but can't figure out why my
customizing isn't working. When I rebind [double-down-mouse-1] to my
function, it gets executed on a double click (from the double-down
event) but the subsequent double-mouse-1 (click) event doesn't have
its usual selection effect. It seems that event does get generated,
though, because a debugging message I put in my function dimmediately
isappears from the echo area (presumably because of the double-mouse-1
event).
However, what's more puzzling is that when I rebind
[double-mouse-1] to my function, the double-down event should run
mouse-drag-region (as it gets demoted to a down-mouse-1 event) but
then the double-mouse (click) event should still run my function. But
it doesn't seem to, because debugging messages in the function don't
get printed. (I checked the *Messages* buffer.)
>
> Before the double-click or double-drag event, Emacs generates a
> "double-down" event when the user presses the button down for the
> second time. Its event type contains `double-down' instead of just
> `down'. If a double-down event has no binding, Emacs looks for an
> alternate binding as if the event were an ordinary button-down event.
> If it finds no binding that way either, the double-down event is
> ignored.
>
> To summarize, when you click a button and then press it again right
> away, Emacs generates a down event and a click event for the first
> click, a double-down event when you press the button again, and finally
> either a double-click or a double-drag event.
>
>
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: customizing double click
2005-08-13 13:18 ` Rajneesh Hegde
@ 2005-08-15 3:52 ` Rajneesh Hegde
0 siblings, 0 replies; 4+ messages in thread
From: Rajneesh Hegde @ 2005-08-15 3:52 UTC (permalink / raw)
> When I rebind [double-down-mouse-1] to my
> function, it gets executed on a double click (from the double-down
> event) but the subsequent double-mouse-1 (click) event doesn't have
> its usual selection effect.
ok, I've resolved this issue:
(defun my-LaTeX-forward-search (event)
"Set point to the position of the mouse pointer and then call the
function TeX-view from AucTeX."
(interactive "e")
(if (and (numberp (posn-point (event-start event)))
(looking-at "\\W"))
(TeX-view)
(mouse-drag-region event)))
i.e. if the click is on a word-constituent character, call
mouse-drag-region with this event (i.e. the double-down event). I'm
not sure why this should work though, as I didn't figure out the code
for mouse-drag-region.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-08-15 3:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-13 0:11 customizing double click Rajneesh Hegde
2005-08-13 11:11 ` Eli Zaretskii
2005-08-13 13:18 ` Rajneesh Hegde
2005-08-15 3:52 ` Rajneesh Hegde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).