Tk Source Code

View Ticket
Login
Bounty program for improvements to Tcl and certain Tcl packages.
2020-06-21
22:47 Ticket [cd051b58] bind.n : MouseWheel documentation: event delivered to item under mouse, not to the focus widget status still Open with 3 other changes artifact: 87ec3e86 user: chrstphrchvz
2019-08-22
15:17 Ticket [38dc27bd] Tk does not support <Button-6> nor <Button-7> events status still Open with 3 other changes artifact: 9b04f7e9 user: chrstphrchvz
14:36 Ticket [5da1d76e] X11: add default bindings for non-emulated horizontal scrolling to Tk 8.6 status still Closed with 5 other changes artifact: 295a4421 user: chrstphrchvz
06:43 Closed ticket [5da1d76e]. artifact: 66edd96e user: jan.nijtmans
06:42
Fix [5da1d76e01]: X11: add default bindings for non-emulated horizontal scrolling to Tk 8.6 check-in: b353987a user: jan.nijtmans tags: core-8-6-branch
2019-08-19
21:58 Ticket [5da1d76e] X11: add default bindings for non-emulated horizontal scrolling to Tk 8.6 status still Open with 3 other changes artifact: e8b05907 user: jan.nijtmans
2019-08-18
21:24 Ticket [5da1d76e]: 4 changes artifact: 2a57c0c9 user: jan.nijtmans
07:03 Ticket [5da1d76e]: 3 changes artifact: 6274ecd9 user: chrstphrchvz
07:00 New ticket [5da1d76e]. artifact: cd93f3ee user: chrstphrchvz

Ticket UUID: 5da1d76e011f3bb30712e6c896d2a170abf3deeb
Title: X11: add default bindings for non-emulated horizontal scrolling to Tk 8.6
Type: RFE Version: 8.6.9.1
Submitter: chrstphrchvz Created on: 2019-08-18 07:00:52
Subsystem: 01. Bindings Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2019-08-22 14:36:05
Resolution: Fixed Closed By: chrstphrchvz
    Closed on: 2019-08-22 14:36:05
Description:

In light of [7ff5f55b] and the recent efforts on the mousewheel-refactor branch, would it be desirable to add default bindings in Tk 8.6 for non-emulated horizontal scrolling on X11 (i.e. buttons 6 and 7), particularly where there are already bindings for emulated horizontal scrolling (i.e. using <Shift-4> and <Shift-5>) or <Shift-MouseWheel> (for non-X11 platforms)? (Currently the only bindings for emulated horizontal scrolling appear to be the listbox, scrollbar, and text widgets; TtkScrollable and the cscroll.tcl demo appear to be the only other instances with <Shift-MouseWheel>.)

This is different from [38dc27bd], as events for binding directly to buttons 6 and higher will likely not arrive until after 8.6, and might even be replaced with <MouseWheel> bindings.

The approach for adding these bindings would be to bind to <ButtonPress> and then check if %b is 6 or 7. (It might also be possible to have button 6 and 7 be translated to <Shift-4> and <Shift-5> on X11, similar to how non-emulated horizontal scrolling already looks to Tk programs on Windows and Aqua as <Shift-MouseWheel>; but I think that is a less desirable approach.)

For more aggressive refactoring of emulated and non-emulated horizontal scrolling into single binding scripts, bit 0 of %s (the event state field), i.e. (%s & 1), can be used to tell if the shift key is pressed.

User Comments: chrstphrchvz added on 2019-08-22 14:36:05:

It works! Thanks for addressing this, Jan. I do like how relatively simple the translation approach is.

I think the main reason I thought that approach might be less desirable is because it has a broader impact than making the default bindings more complex by checking %b. Even though I imagine Tk program developers are more likely to use <Shift-4>/<Shift-5> for horizontal scrolling than to use %b to detect buttons 6/7 in the absence of <6>/<7>, it might want to be noted that existing usage of %b == 6 or %b == 7 (without equivalent <Shift-4>/<Shift-5> bindings) will break, as well as usage where shift+6/shift+7 has a different effect than 6/7 (although such usage might not be a good idea, since <Shift-MouseWheel> on other platforms just indicates horizontal scrolling, not whether the shift key is actually pressed). I don't think I'm a sufficiently experienced Tk programmer to tell whether that is an acceptably unlikely inconvenience, but maybe the important thing is that 6/7 were not well-supported to begin with, and this change is welcome.


jan.nijtmans added on 2019-08-22 06:43:42:
Fixed in core-8-6-branch.

jan.nijtmans added on 2019-08-19 21:58:01:

Added experimental https://core.tcl-lang.org/tk/timeline?r=rfe-5da1d76e01-bis branch, in which Buttons 6/7 are simply translated to Shift 4/5. As suggested. Surprisingly simple!


jan.nijtmans added on 2019-08-18 21:24:51:
Please test/review the [rfe-5da1d76e01] branch. Does this work, and does what this RFE suggests for you?

I think that it's no problem defining additional <ButtonPress> bindings. If user programs do that, the User program definition wil break the default Button 6/7 handling, but it doesn't work either way now so that's not a regression. But I would like to do more testing (help appreciated!) before definitely concluding that it doesn't do harm.

This branch should be "merge-mark"-ed to trunk, since trunk already has proper Button 6/7 handling.