unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Cc: bug-gnu-emacs@gnu.org
Subject: RE: mouse wheel support in Emacs 21.3.50
Date: Mon, 25 Oct 2004 09:31:34 -0700	[thread overview]
Message-ID: <DNEMKBNJBGPAOPIJOOICCEKNCAAA.drew.adams@oracle.com> (raw)
In-Reply-To: <u7jpfwz9p.fsf@jasonrumney.net>

Hi Jason,

Thanks for a detailed explanation. Very clear.

FYI, I wrote an application that lets you use the mouse wheel (or the arrow
keys) to incrementally modify Emacs things (anything, really). This is how I
treat the mouse wheel in both Emacs 20 and 21:

        (cond ;; Emacs 20 mouse wheel.
              ((and (consp evnt) (equal 'mouse-wheel (event-basic-type (car
evnt))))
               ...)
              ;; Emacs 21 mouse wheel: `mwheel.el'
              ((and (consp evnt)
                    (member (event-basic-type (car evnt)) '(wheel-up
wheel-down)))
               (let ((button (mwheel-event-button evnt)))
                 (cond ((eq button mouse-wheel-down-event) ...)
                       ((eq button mouse-wheel-up-event) ...)
                       (t (error "Bad binding in mwheel-scroll"))))

Here is the application, in case you're interested:
http://www.emacswiki.org/cgi-bin/wiki/DoReMi.

Thanks,

  Drew


-----Original Message-----From: Jason Rumney
"Drew Adams" <drew.adams@oracle.com> writes:

> 1. Bug?: Searching Elisp Info for "wheel" shows nothing that is current.
It
> shows the same stuff as for Emacs 20 ("mouse-wheel"...). Yet, looking at
> real mouse wheel events, I see stuff like wheel-up that is not in Info,
and
> I don't see "mouse-wheel" in real events.

I have updated the elisp manual to reflect the current implementation.

The rationale behind it was to separate out the wheel-up and
wheel-down events to make it easier for end users to rebind them (the
single mouse-wheel event was unusual in that you had to look at the
DELTA parameter to see if it was positive or negative, most mouse and
keyboard events are simpler). It also allowed us to reuse the mwheel
implementation, which had some extra features that the previous
Windows-only support did not have.

> 3. I'd like to know how to interpret the components of the various mouse
> events. In Emacs 20 this was simple; there was just the POSITION and the
> DELTA. Now I see lots of components (with no Elisp Info)

There is only POSITION (which like in the old mouse-wheel event is a list).

> In particular, if I call read-event and get mouse wheel events, where
> can I get the DELTA info that used to be there?

That is where the double- and triple- modifiers come in, for
compatibility with the mouse-4 and mouse-5 way of handling the mouse
wheel.

> Actually, I can pretty much see what's going on in mwheel-scroll, in terms
> of getting the DELTA info (amount), but before I base new code on what
> happens in (this 2002) mwheel-scroll code, I wonder if this is a good
model;
> that is, if this deals with the latest event structure and is the
> recommended (i.e. current) way to go about things.

I can't see this changing unless X gets proper mouse wheel support
instead of emulating mouse-4 and -5. Unfortunately I think too many
X applications now have mouse-4 and -5 hardcoded for that to change.
One thing that could change is that mouse-4 and mouse-5 could be
translated to wheel-up and wheel-down internally by Emacs, but because
they come to Emacs as mouse button events, wheel-up and wheel-down
will not be able to change I think (eg reintroducing DELTA).

> And the whole treatment of the wheel as buttons 4 & 5 is not clear
> to me.

That is specific to X. On Windows and Mac, wheel-up and wheel-down are
used. If you want to write portable code, use mouse-wheel-up-event and
mouse-wheel-down-event to determine what events you should be dealing
with.

> And what if (as I do) I have 5 mouse buttons and a wheel?

If you are on Windows or Mac, no problem, since the wheel has its own
events. If you're on X, you'll have to map them to mouse-6 and mouse-7
or other applications will become confused (Emacs can be made to
handle them as -4 and -5, with the wheel as -6 and -7, but other
applications are not so flexible).

> 5. Finally, although I have little real hope for this, are there any
> guidelines for trying to make code that deals with making the mouse wheel
> work in both Emacs 20 and 21?

Since Emacs 20 had different mouse wheel handling for different
platforms, such guidelines would be quite complex, as would your code
for handling the differences.

I've never heard of anyone using the mouse wheel in Emacs for anything
other than its default scrolling behaviour, so I'm not sure there is
any demand for such a guide.

  reply	other threads:[~2004-10-25 16:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.3845.1096007084.1998.bug-gnu-emacs@gnu.org>
2004-09-24 17:25 ` mouse wheel support in Emacs 21.3.50 Stefan Monnier
2004-10-24 22:02 ` Jason Rumney
2004-10-25 16:31   ` Drew Adams [this message]
2004-09-24  6:17 Drew Adams

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=DNEMKBNJBGPAOPIJOOICCEKNCAAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    --cc=bug-gnu-emacs@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).