Tk Source Code

View Ticket
Login
2020-10-23
12:47 Closed ticket [681692ffff]: Map <Button-4/5> to <MouseWheel> on UNIX plus 7 other changes artifact: 75df9a200d user: jan.nijtmans
2019-04-01
15:16 Ticket [681692ffff]: 4 changes artifact: eb11cabd3c user: chrstphrchvz
14:40 Ticket [4a8d97d370] Document & support <MouseWheel> event on unix status still Open with 4 other changes artifact: abb8bcf40e user: chrstphrchvz
2018-06-29
18:27 Ticket [681692ffff] Map <Button-4/5> to <MouseWheel> on UNIX status still Open with 4 other changes artifact: 7a7855062d user: fvogel
2017-09-08
10:48 Ticket [681692ffff]: 3 changes artifact: 800395cfc4 user: fvogel
2017-09-07
19:58 Ticket [2b8fa6fd91] ttk::scrollbar is missing MouseWheel bindings status still Open with 3 other changes artifact: f015b1b73e user: fvogel
2017-03-14
15:52 Ticket [681692ffff] Map <Button-4/5> to <MouseWheel> on UNIX status still Open with 7 other changes artifact: e4c56893bb user: griffin
2010-01-14
01:51 Ticket [681692ffff]: 4 changes artifact: 53963b8c0d user: tom_goddard
2004-12-13
21:17 Ticket [681692ffff]: 1 change artifact: d9d7beeff8 user: dkf
2003-03-09
09:05 Ticket [681692ffff]: 4 changes artifact: 598d723a11 user: xtifr
2003-02-06
14:55 New ticket [681692ffff]. artifact: c3b817cad0 user: tallniel

Ticket UUID: 681692
Title: Map <Button-4/5> to <MouseWheel> on UNIX
Type: RFE Version: None
Submitter: tallniel Created on: 2003-02-06 14:55:24
Subsystem: 01. Bindings Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2020-10-23 12:47:15
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2020-10-23 12:47:15
Description:
Currently on UNIX, mousewheel events are mapped to
mouse buttons 4 and 5. On Windows, there is a separate
<MouseWheel> event. I understand that historically,
buttons 4 and 5 are used on UNIX, but in the interests
of hiding platform-specific details, it would useful to
be able to portably register interest in mousewheel
events, without having to work out how those are
conveyed on a particular platform.
To this end, I propose adding a simple mapping to Tks
script library so that button 4/5 events also generate
an appropriate <MouseWheel> event. This can be done
easily in two lines of code:

bind all <Button-4> {event generate %W <MouseWheel>
-delta 1}
bind all <Button-5> {event generate %W <MouseWheel>
-delta -1}

This seems to get things working on my Linux box. I
haven't looked at the delta values on Windows, so they
may need some tweaking (finding a suitable default
value, and working out whether up is negative or positive).
I think this is a small change, but one which does
quite a lot in hiding platform specific details, in a
backwards-compatible way.
User Comments: jan.nijtmans added on 2020-10-23 12:47:15:

Since TIP #474 is in Tk 8.7 now, this can be closed. Done.


chrstphrchvz added on 2019-04-01 15:16:47:

I believe [4a8d97d370] is a duplicate of this.

Regarding the implementation currently in the tip474-uniform-mouse-wheel branch: does it convert events for buttons 4 and 5 into MouseWheel events on platforms other than X11? I don't think Tk should begin interpreting buttons 4 and 5 as scrolling on Windows/Aqua.


fvogel added on 2018-06-29 18:27:47:
There is discussion currently about this on Tcl-Core list.

fvogel added on 2017-09-08 10:48:03:

TIP #474 deals with this.


griffin added on 2017-03-14 15:52:29:
I agree that it is painful to have different platform dependent 
mouse wheel definitions.
I am concerned that the definition of Windows <MouseWheel> 
and X11's <Button-4>, etc., are fundamentally different 
making a translation non-trivial.  I have seen inconsistencies 
in different mouse devices on Windows that don't behave as 
expected with the simple "%D/120" algorithm.   
So proceed with caution before just blindly hard-wiring these 
2 events together.  More research is required.

tom_goddard added on 2010-01-14 01:51:55:
The MouseWheel binding doing nothing on X11 platforms has caused us headaches in our Windows/Mac/Linux molecular visualization program UCSF Chimera.  It is one of too many cases where we have to special-case the Tk code depending on operating system.  We'd love to see this fixed.

xtifr added on 2003-03-09 09:05:48:
Logged In: YES 
user_id=25775

According to a fellow Debian developer, there's a way to ask
X which buttons control ZAxisMapping.  (He also informs me
that it's not always 4/5; some people use 6/7.) I'll try to
get more details, maybe even see if I can whip up a proper
patch.