[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
recommended way to bind mouse-wheel events
From: |
Drew Adams |
Subject: |
recommended way to bind mouse-wheel events |
Date: |
Mon, 16 Feb 2009 14:41:21 -0800 |
I've read the Elisp manual, node Misc Events, and I've looked at the little bit
of vanilla Elisp code that uses the mouse wheel, but I still have a question
about binding the wheel.
In various places, I've come across code such as this:
(defvar my-map
(let ((my-map (make-sparse-keymap)))
(when mouse-wheel-mode
(mapc (lambda (key)
(define-key my-map key 'my-scroll))
'([mouse-4] [mouse-5]
[C-mouse-4] [C-mouse-5]
[S-mouse-4] [S-mouse-5])))
my-map)
"...")
On Windows, at least with my 5-button mouse, that doesn't work: `mouse-4' and
`mouse-5' are separate mouse buttons.
This works for me, on Windows:
(defvar my-map
(let ((my-map (make-sparse-keymap)))
(when mouse-wheel-mode
(mapc (lambda (key)
(define-key my-map key 'my-scroll))
(list (vector mouse-wheel-up-event)
(vector mouse-wheel-down-event)
(vector (list 'control mouse-wheel-up-event))
(vector (list 'control mouse-wheel-down-event))
(vector (list 'shift mouse-wheel-up-event))
(vector (list 'shift mouse-wheel-down-event)))))
my-map)
"...")
Questions:
Will this code, which uses the event variables, work also on non-Windows
platforms? If so, is this a good way to do it, or is there a better way?
Shouldn't this be documented? (Mice with wheels have been around for decades.)
- recommended way to bind mouse-wheel events,
Drew Adams <=