Make mouse scroll wheels work in xemacs

Mar 05, '03 08:30:00AM

Contributed by: ths291

To make the scroll wheel work in XEmacs, edit your .emacs file to include the text in the second part of this hint.

[robg adds: I haven't tested this one, so if you do, please post a comment as to whether or not it worked for you...]

;;=======================================
;;        scroll on  mouse wheel
;;=======================================

;; scroll on wheel of mouses
(define-key global-map 'button4
  '(lambda (&rest args)
    (interactive) 
    (let ((curwin (selected-window)))
      (select-window (car (mouse-pixel-position)))
      (scroll-down 5)
      (select-window curwin)
)))
(define-key global-map [(shift button4)]
  '(lambda (&rest args)
    (interactive) 
    (let ((curwin (selected-window)))
      (select-window (car (mouse-pixel-position)))
      (scroll-down 1)
      (select-window curwin)
)))
(define-key global-map [(control button4)]
  '(lambda (&rest args)
    (interactive) 
    (let ((curwin (selected-window)))
      (select-window (car (mouse-pixel-position)))
      (scroll-down)
      (select-window curwin)
)))

(define-key global-map 'button5
  '(lambda (&rest args)
    (interactive) 
    (let ((curwin (selected-window)))
      (select-window (car (mouse-pixel-position)))
      (scroll-up 5)
      (select-window curwin)
)))
(define-key global-map [(shift button5)]
  '(lambda (&rest args)
    (interactive) 
    (let ((curwin (selected-window)))
      (select-window (car (mouse-pixel-position)))
      (scroll-up 1)
      (select-window curwin)
)))
(define-key global-map [(control button5)]
  '(lambda (&rest args)
    (interactive) 
    (let ((curwin (selected-window)))
      (select-window (car (mouse-pixel-position)))
      (scroll-up)
      (select-window curwin)
)))
This effectively defines button 4 and 5 as up and down keys, enabling you to scroll with your scroll wheel.

Comments (6)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030302234327912