emacs-devel
[Top][All Lists]
Advanced

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

Mac emacs scroll bars


From: Steven Tamm
Subject: Mac emacs scroll bars
Date: Thu, 8 Jul 2004 09:05:31 -0700

I have been trying to get the scrollbar to continuously scroll if
for example I hold down the mouse button on the up or down arrows,
but so far I have failed since I am a novice with the emacs source
code.
My guess is that it can be done in Lisp-level using track-mouse and
sit-for.  But it would not be so easy, judging from complicated codes
in mouse.el.
I'm not sure one can do it at the lisp level. The particular problem is that holding down the mouse button doesn't generate the same kind of events on the mac that holding down a key would (i.e. autorepeat events). Because of the event model, read-event hangs until you move the mouse. So the following code:

(defun mac-scroll-down-line ()
  (track-mouse
    (let* ((done nil))
      (while (not done)
        (scroll-down 1)
        (setq done (memq (car-safe (read-event))
                    '(mouse-1 double-mouse-1 triple-mouse-1 drag-mouse-1)))
        ))))

does what you'd want if you move the mouse around... But read-event wouldn't do the right thing. So it appears that there would have to be a new C function added that would call the new Carbon function GetCurrentEventButtonState (or Button on MAC_OS) so that "mouse-down" could be "tested" from the lisp code.

Then the code would look something like this

(defun mac-scroll-down-line ()
  (track-mouse
    (let* ((done nil))
      (while (not done)
        (scroll-down 1)
        (sit-for mouse-delay) ;; possibily have initial and subsequent delays
        (setq done (mac-is-button-down)))
      (mac-scroll-ignore-events))))

I added mac-scroll-ignore-events today to CVS. This would be more Mac like, but have the annoying problem of having a 1/4 second delay after you let go of the mouse. Perhaps the better solution would be to make a version of (read-event) that would produce null events?

I have included a very small patch to keyboard.c to disable emacs
from interpreting double and triple clicking in the scrollbar. This
makes it much easier for me to use the scrollbar. I am sending you
the patch because I see that you have been contributing heavily to
the development of emacs, and I'm not sure where else to send the
patch.  Please examine and/or try the patch and if you feel that it
is useful, feel free to submit the patch.

Maybe similar thing can alternatively be done with

    (defun mac-scroll-down ()
      (track-mouse
        (while (not (meeq (car-safe (read-event))
                          '(mouse-1 double-mouse-1 triple-mouse-1))) nil)
        (scroll-down)))

(Likewise for mac-scroll-down-line, mac-scroll-up, and
mac-scroll-up-line in term/mac-win.el.)

Although both of them are not complete (e.g., drag within non-handle
scrollbar area), they are better than before.

I checked in a change similar to this. I forgot to add drag-mouse-1 to the list of ignorable events, though.

-Steven





reply via email to

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