TransWikia.com

tooltip-functions not working?

Emacs Asked by toomas on August 15, 2020

Years ago, when Emacs was at 21.*, I had a function that displayed a tooltip when I hovered the mouse on certain words in the buffer. Now, in 26.3, I want to use that function again, but it does not work any more, apparently because Emacs is not passing mouse movement events to it.

Minimal example that worked fine in Emacs 21 but does nothing in Emacs 26:

(defun my-tooltip (event)
  (interactive "e")
  (tooltip-show "got mouse movement event")
  t)

(progn
  (tooltip-mode)
  (set (make-local-variable 'track-mouse) t)
  (setq tooltip-functions nil)
  (add-hook 'tooltip-functions 'my-tooltip))

One more thing: when I did M-x describe-key and moved the mouse, older Emacs versions used to tell me which command, if any, was bound to mouse-movement. In the same situation, Emacs 26 does nothing — it obviously does not see that I am moving the mouse, even when I set track-mouse to t globally.

Running Emacs with -Q does not change anything.

How should I catch mouse movement events in Emacs 26?

One Answer

Not exactly an answer, but a dirty workaround: give up using tooltip-functions and bind the function directly to mouse-movement, like this:

(defun my-tooltip (event)
  (interactive "e")
  (tooltip-show "got mouse movement event")
  t)
(tooltip-mode)
(set (make-local-variable 'track-mouse) t)
(local-set-key (kbd "<mouse-movement>") 'my-tooltip)

Answered by toomas on August 15, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP