unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to handle mouse events
@ 2006-04-24 10:23 Tassilo Horn
  2006-04-25 15:05 ` How to handle mouse events [SOLVED] Tassilo Horn
  0 siblings, 1 reply; 2+ messages in thread
From: Tassilo Horn @ 2006-04-24 10:23 UTC (permalink / raw)


Hi,

I wrote a simple dictionary with emacs bindings. One feature I want to
implemenet now is to open a tooltip with the translation of the word the
mouse is pointing at.

So far I wrote this code:

,----
| (defvar rdictcc-tooltip-mode nil
|   "Indicates wheather the rdictcc tooltip mode is active.")
| (nconc minor-mode-alist '((rdictcc-tooltip-mode " RDictCc")))
|
| (defun rdictcc-translate-word-under-mouse (event)
|   "Display translations of the word at the cursor in a tooltip."
|   (interactive "e")
|   (let ((word (save-window-excursion
|                 (save-excursion
|                   (mouse-set-point event)
|                   (current-word t t)))))
|     (message "Word is %s" word)
|     (tooltip-show (rdictcc-translate-word-to-string word))))
|
| (defun rdictcc-tooltip-mode (&optional arg)
|   "Display tooltips for the current word."
|   (interactive "P")
|   (require 'tooltip)
|   (let ((val (if arg
|                  (> (prefix-numeric-value arg) 0)
|                (not rdictcc-tooltip-mode))))
|     (make-local-variable 'rdictcc-tooltip-mode)
|     (setq rdictcc-tooltip-mode val)
|     (tooltip-mode 1)
|     (add-hook 'tooltip-hook 'rdictcc-translate-word-under-mouse t t)
|     (make-local-variable 'track-mouse)
|     (setq track-mouse val)))
`----

But there are no tooltips and it seems that I never enter
`rdictcc-translate-word-under-mouse', or at least "Word is <word>" is
never printed in the echo area.

If I enter below code in *scratch* buffer, I get a tooltip with the
translation.

,----[ in *scratch* ]
| (track-mouse
|   (rdictcc-translate-word-under-mouse (read-event)))
`----

Any help?

Bye,
Tassilo

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to handle mouse events [SOLVED]
  2006-04-24 10:23 How to handle mouse events Tassilo Horn
@ 2006-04-25 15:05 ` Tassilo Horn
  0 siblings, 0 replies; 2+ messages in thread
From: Tassilo Horn @ 2006-04-25 15:05 UTC (permalink / raw)


Hi,

I got things working by using the help-echo text property.

Bye,
Tassilo
-- 
My opinions may have changed, but not the fact that I am right.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-04-25 15:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-24 10:23 How to handle mouse events Tassilo Horn
2006-04-25 15:05 ` How to handle mouse events [SOLVED] Tassilo Horn

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).