all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Mac emacs scroll bars
       [not found] ` <wl7jtety5y.wl@church.math.s.chiba-u.ac.jp>
@ 2004-07-08 16:05   ` Steven Tamm
  2004-07-09  9:53     ` YAMAMOTO Mitsuharu
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Tamm @ 2004-07-08 16:05 UTC (permalink / raw)
  Cc: emacs-devel

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

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

* Re: Mac emacs scroll bars
  2004-07-08 16:05   ` Mac emacs scroll bars Steven Tamm
@ 2004-07-09  9:53     ` YAMAMOTO Mitsuharu
  2004-07-09 15:27       ` Lennart Staflin
  0 siblings, 1 reply; 3+ messages in thread
From: YAMAMOTO Mitsuharu @ 2004-07-09  9:53 UTC (permalink / raw)
  Cc: Martin Otte, emacs-devel

>>>>> On Thu, 8 Jul 2004 09:05:31 -0700, Steven Tamm <steventamm@mac.com> said:

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

One can tell whether an event has been available by examining the
return value of sit-for.  Here is an example:

(defun mac-scroll-down-line ()
  (track-mouse
    (let ((done nil)
	  event type)
      (while (not done)
	(scroll-down 1)
	(unless (sit-for mouse-delay) ;; possibly have initial and subsequent delays
	  (setq event (read-event))
	  (setq type (event-basic-type event))
	  (cond ((eq type 'mouse-1)
		 (setq done t))
		((eq type 'mouse-movement)
		 ;; should do something
		 )))))))

Maybe some subtle cases should be added to the above cond-expression.

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

Perhaps the following is simpler.  (I should have noticed that.)

(defun mac-scroll-ignore-events ()
  ;; Ignore confusing non-mouse events
  (while (not (eq (event-basic-type (read-event)) 'mouse-1))
    nil))

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

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

* Re: Mac emacs scroll bars
  2004-07-09  9:53     ` YAMAMOTO Mitsuharu
@ 2004-07-09 15:27       ` Lennart Staflin
  0 siblings, 0 replies; 3+ messages in thread
From: Lennart Staflin @ 2004-07-09 15:27 UTC (permalink / raw)
  Cc: emacs-devel


On 9 jul 2004, at 11:53, YAMAMOTO Mitsuharu wrote:
> (defun mac-scroll-ignore-events ()
>   ;; Ignore confusing non-mouse events
>   (while (not (eq (event-basic-type (read-event)) 'mouse-1))
>     nil))
>

You should not ignore all events but mouse-1, unless you are sure that 
there will be a mouse-1 event before any other interesting event. I 
don't think that is guaranteed, because of the way events are 
simplified/translated. The code can be called from a double mouse down 
event translated to single mouse down and then there won't be a mouse-1 
event, but a double-mouse-1 (or whatever it is called). You end up 
stuck in the loop ignoring events that should be handled.

//Lennart Staflin

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

end of thread, other threads:[~2004-07-09 15:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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   ` Mac emacs scroll bars Steven Tamm
2004-07-09  9:53     ` YAMAMOTO Mitsuharu
2004-07-09 15:27       ` Lennart Staflin

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.