all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Steven Tamm <steventamm@mac.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Mac emacs scroll bars
Date: Thu, 8 Jul 2004 09:05:31 -0700	[thread overview]
Message-ID: <A3217450-D0F8-11D8-A9B1-00039390AB82@mac.com> (raw)
In-Reply-To: <wl7jtety5y.wl@church.math.s.chiba-u.ac.jp>

>> 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	other threads:[~2004-07-08 16:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <7627C10A-CF84-11D8-8F92-00050260B859@duke.edu>
     [not found] ` <wl7jtety5y.wl@church.math.s.chiba-u.ac.jp>
2004-07-08 16:05   ` Steven Tamm [this message]
2004-07-09  9:53     ` Mac emacs scroll bars YAMAMOTO Mitsuharu
2004-07-09 15:27       ` Lennart Staflin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A3217450-D0F8-11D8-A9B1-00039390AB82@mac.com \
    --to=steventamm@mac.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.