emacs-devel
[Top][All Lists]
Advanced

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

keymap property ignored for mouse click on overlay


From: Drew Adams
Subject: keymap property ignored for mouse click on overlay
Date: Sun, 30 Mar 2008 11:24:44 -0700

emacs -Q
 
(setq foo-map (make-sparse-keymap))
(define-key foo-map [mouse-2] 'bar)
 
(defun foo (beg end)
  (interactive "r")
  (let ((overlay (make-overlay beg end)))
    (overlay-put
     overlay 'display
     (propertize "xxxxxxxxx" 'face 'font-lock-constant-face))
    (overlay-put overlay 'keymap foo-map)))
 
(defun bar (event) (interactive "e") (message "BAR"))
 
Here's some text: aaaaaaaaaaaaaaaaaaaaaaa
 
Select one or more of the a's and do M-x foo, to apply the overlay to just
those a's.
 
Put point somewhere outside the displayed "xxxxxxxxx" overlay.
 
Click mouse-2 anywhere on the displayed "xxxxxxxxx". What happens, it seems,
is that, since point is not on the a's that have the overlay, keymap foo-map
doesn't apply. Clicking mouse-2 therefore just calls the default mouse-2
binding, e.g. mouse-yank-at-click. That sets point so that it is at the
beginning of the overlaid text, so that a second mouse-2 click on the
displayed "xxxxxxxxx" does call bar.
 
If that's what's happening, how can foo be defined so that a first click on
the displayed "xxxxxxxxx" calls bar?
 
I'm guessing that the mouse click on the overlay is noted not as being
a click on a buffer position that has the overlay but on a buffer
position that is under the displayed "xxxxxxxxx" but is actually
outside the text that has the overlay.
 
What I'm looking for is for the click to be perceived by Emacs as happening
on the overlay, and for the overlay's keymap to apply over the full extent
of the overlay, not just at its beginning, causing the overlay's keymap
binding to take effect.
 
Note that this is specifically about overlays, not text properties.
 
 
 
In GNU Emacs 22.1.90.1 (i386-mingw-nt5.1.2600)
 of 2008-01-30 on PRETEST
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --cflags -Ic:/gnuwin32/include'
 





reply via email to

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