Tk Source Code

View Ticket
Login
2019-08-26
07:39 Ticket [38dc27bd1d] Tk does not support <Button-6> nor <Button-7> events status still Closed with 5 other changes artifact: ef7679a7cf user: jan.nijtmans
2019-08-25
17:53 Ticket [38dc27bd1d]: 5 changes artifact: c9bb785a36 user: chrstphrchvz
2019-08-22
21:58 Closed ticket [38dc27bd1d]. artifact: 7379e33d6e user: jan.nijtmans
21:48
Fix [38dc27bd1d]: Tk does not support &lt;Button-6&gt; nor &lt;Button-7&gt; events. Was already almost done, just the [https://core.tcl-lang.org/tk/artifact/5c2d5507c89ab2cb?ln=360,395|modArray] changes were still missing. Add test-cases too check-in: 40159ae356 user: jan.nijtmans tags: trunk
15:17 Ticket [38dc27bd1d] Tk does not support <Button-6> nor <Button-7> events status still Open with 3 other changes artifact: 9b04f7e919 user: chrstphrchvz
2019-08-18
07:00 New ticket [5da1d76e01] X11: add default bindings for non-emulated horizontal scrolling to Tk 8.6. artifact: cd93f3ee54 user: chrstphrchvz
2019-07-30
11:17
Follow-up to [38dc27bd1d0ecd682aafde]: Tk does not support <Button-6> nor <Button-7> events. This commit adds hardware-support for buttons 6-9 on MacOSX, and handles masking correct for all buttons 6-9. Not complete yet, but this is as far as we can go without needing a TIP. check-in: 76f0a84016 user: jan.nijtmans tags: trunk
2019-07-24
18:00 Ticket [38dc27bd1d] Tk does not support <Button-6> nor <Button-7> events status still Open with 4 other changes artifact: a05fab6c33 user: chrstphrchvz
13:01 Ticket [6ff8f7b07a] Platform-independent way of using middle/right mouse button status still Open with 4 other changes artifact: 75b10e9b3e user: chrstphrchvz
10:52 Ticket [1fb7af623a] Add support for buttons 4 and 5 to Windows status still Open with 4 other changes artifact: f0fff9f3db user: chrstphrchvz
2019-07-23
15:24 Ticket [38dc27bd1d] Tk does not support <Button-6> nor <Button-7> events status still Open with 3 other changes artifact: b02cb3caae user: jan.nijtmans
15:24
Fix [38dc27bd1d]: Tk does not support <Button-6> nor <Button-7> events. Now handle all events up to Button 9. On Windows and Mac, Buttons 8 and 9 are used for the mouse side buttons (as X11 already does). TIP needed for this. check-in: a2b2bc1877 user: jan.nijtmans tags: tip474
13:30 Ticket [38dc27bd1d] Tk does not support <Button-6> nor <Button-7> events status still Open with 4 other changes artifact: 7af5e92984 user: chrstphrchvz
07:44 Ticket [1fb7af623a] Add support for buttons 4 and 5 to Windows status still Open with 3 other changes artifact: f41b140002 user: jan.nijtmans
2018-06-29
18:30 Ticket [38dc27bd1d] Tk does not support <Button-6> nor <Button-7> events status still Open with 3 other changes artifact: 5698e2309a user: fvogel
2016-04-11
13:19 Open ticket [38dc27bd1d]. artifact: 360ca82546 user: jan.nijtmans
2016-04-10
19:44 Ticket [38dc27bd1d]: 5 changes artifact: a2dbeaf9b2 user: fvogel
2016-03-23
14:19 Closed ticket [38dc27bd1d]. artifact: fa0add927b user: jan.nijtmans
2016-03-22
11:47
Fix [38dc27bd1d0ecd68]: Tk does not support <Button-6> nor <Button-7> events check-in: e189cd8e65 user: jan.nijtmans tags: trunk
08:15 Ticket [38dc27bd1d] Tk does not support <Button-6> nor <Button-7> events status still Open with 4 other changes artifact: c78e569017 user: adrianmedranocalvo
2016-03-14
14:13 Ticket [38dc27bd1d]: 3 changes artifact: 144e3fe95b user: jan.nijtmans
14:09
Suggested fix for [38dc27bd1d0ecd68]: Tk does not support <Button-6> nor <Button-7> events. With test-cases and doc change. check-in: 56355af1f8 user: jan.nijtmans tags: bug-38dc27bd1d0ecd68
2016-03-11
15:30 Ticket [38dc27bd1d] Tk does not support <Button-6> nor <Button-7> events status still Open with 3 other changes artifact: aab0ae1661 user: fvogel
10:00 Ticket [38dc27bd1d]: 4 changes artifact: 669a4f6455 user: oehhar
08:34 Ticket [38dc27bd1d]: 3 changes artifact: 47382ad9f5 user: fvogel
2016-03-10
10:18 New ticket [38dc27bd1d]. artifact: fe8712f69a user: adrianmedranocalvo

Ticket UUID: 38dc27bd1d0ecd682aafdebabc7ee9fe9ad0943b
Title: Tk does not support <Button-6> nor <Button-7> events
Type: Bug Version: 8.6.5
Submitter: adrianmedranocalvo Created on: 2016-03-10 10:18:42
Subsystem: 69. Events Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2019-08-26 07:39:26
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2019-08-26 07:39:26
Description:
Most modern mouses report horizontal scroll events as buttons 6 and 7 under X11.  Tk does not allow specifying an event handler directly for them:

::bind all <Button-6> {puts "Pressed button 6"}
specified keysym "6" for non-key event

Even more, using the usual short-hand notation for button events unexpectedly binds the keyboard instead:
::bind all <6> {puts "Pressed button 6"}
# Scroll does nothing, but pressing "6" key prints the above message.

Tk should support horizontal scroll buttons on X11.  Ideally, the button number should not have any restriction, although the more conservative option of supporting up to button 7 would be welcome.  The patch below implements the latter:

diff --git i/generic/tkBind.c w/generic/tkBind.c
index 9cd3b7b..7e489b6 100644
--- i/src/tk8.6.4/generic/tkBind.c
+++ w/src/tk8.6.4/generic/tkBind.c
@@ -3937,7 +3937,7 @@ ParseEventDescription(
        p = GetField(p, field, FIELD_SIZE);
     }
     if (*field != '\0') {
-       if ((*field >= '1') && (*field <= '5') && (field[1] == '\0')) {
+       if ((*field >= '1') && (*field <= '7') && (field[1] == '\0')) {
            if (eventFlags == 0) {
                patPtr->eventType = ButtonPress;
                eventMask = ButtonPressMask;
User Comments: jan.nijtmans added on 2019-08-26 07:39:26:
@chrstphrchvz: Thanks for the correction: Yes, you are right. It's indeed expected.

For 8.6 the importance is that scripts don't need to be modified, that's not expected in a patch-release. In 8.7, there are more possibilities to change things.

chrstphrchvz added on 2019-08-25 17:53:35:

…unless binding to <Button> and test for the right %b value

I'm not sure this is the case given how the translation is implemented. Even when using <Button>, %b and (%s & 1) appear to use the post-translation values, which I think is expected.


jan.nijtmans added on 2019-08-22 21:58:13:

In Tk 8.6, a simple translation from Button6/7 to Shift-Button4/5 was added, but still scripts cannot bind to those buttons (unless binding to <Button> and test for the right %b value).

So, in Tk 8.6, I consider it only partially fixed, in the sense that the Buttons work but cannot be accessed from scripts like the other buttons. In Tk 8.7 that should be fully fixed now: We can now create bindings for buttons up to 9, in the same way as Buttons 1-5 in Tk 8.6

More changes are in preparation (e.g. Interchanging Buttons 2 and 3 on Mac, and translating buttons 4-7 on X11 to MouseWheel events), but that's out-of-scope for this Ticket. TIP #474 is in preparation for that (implementation almost finished, but not complete yet)

So, closing this one.

Thanks!


chrstphrchvz added on 2019-08-22 15:17:23:

I believe this issue is fixed in Tk 8.6.10; see [b353987a]. As part of addressing [5da1d76e], buttons 6 and 7 will be translated to <Shift-4> and <Shift-5> respectively on X11, so that those bindings handle both emulated (shift+vertical scrolling) and non-emulated horizontal scrolling. The approach for later Tk versions might be different, though.


chrstphrchvz added on 2019-07-24 18:00:29:

Jan, thank you for your quick effort on this in response to [1fb7af62]. I am taking a look at the branch, but have not tested it (I have yet to try 8.7 at all), nor do I have any real feedback as to how the approach might change other than having it also address [6ff8f7b0]. I would not call myself a seasoned C expert, so were I to try offering any nitpicks, this is what I would think of so far:

  • Should mask/state variables, functions, etc. consistently be of type unsigned int? If so, possible instances to adjust (there are many more instances in the existing code):
    • int mask in CanvasBindProc() (tkCanvas.c)
    • int TkGetButtonMask() and int buttonMasks[] (tkEvent.c)
    • the int mouseButtonState field in struct TkDisplay (tkInt.h)
    • the int state field in struct TkCanvas (tkCanvas.h)
    • might not need to cast result of TkGetButtonMask() in TkPointerEvent() (tkGrab.c)
    • int state, mask, changes in Tk_UpdatePointer() (tkPointer.c)
  • Should AnyButtonMask be redefined/reintroduced as meaning the mask corresponding to AnyButton (X.h)? If so, should it be used instead of literal 0 in places where Button1Mask etc. appear? Instances of this:
    buttonMasks[] = {0, Button1Mask, …}

    and

    return (button > Button9) ? 0 : buttonMasks[button];

    in TkGetButtonMask().

  • In tkProcessMouseEvent() and in ButtonModifiers2State() (tkMacOSXMouseEvent.c), I wonder if there is a better way to express this:
    state |= (buttons & 0x1F) * Button1Mask;

    One option might be to just expand it out (as done for TkWinGetModifierState() in tkWinPointer.c), since there's only 5 buttons to handle, and it would probably be easier to accommodate buttons 2 and 3 being swapped ([6ff8f7b0])—whereas the currently compact bitshift approach might become complicated:

    if (buttonState & 0x01)
        state |= Button1Mask;
    if (buttonState & 0x02)
        state |= Button2Mask; /* change to Button3Mask to match Windows and X11 */
    if (buttonState & 0x04)
        state |= Button3Mask; /* change to Button2Mask to match Windows and X11 */
    if (buttonState & 0x08)
        state |= Button4Mask;
    if (buttonState & 0x10)
        state |= Button5Mask;


jan.nijtmans added on 2019-07-23 15:24:40:
Fully implemented now in the [bug-38dc27bd1d] branch. Please test (who-ever can)!

chrstphrchvz added on 2019-07-23 13:30:06:

Cc'ing myself in case of updates.

Note that the xdotool click utility can be used for testing, should anyone not have access to capable hardware.


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

jan.nijtmans added on 2016-04-11 13:19:34:
Thanks François, guess you are right that the solution is not complete yet.

fvogel added on 2016-04-10 19:44:06:

Shouldn't modArray be updated as well when fixing this bug?


jan.nijtmans added on 2016-03-23 14:19:51:
Fixed in trunk. Will be available in Tk 8.7

adrianmedranocalvo (claiming to be Adrián Medraño Calvo <support@prs.de>) added on 2016-03-22 08:15:46:
Sorry for the delay.

Jan, I have tested the changes.  The functionality works: the horizontal scroll buttons are now recognized.  One of the changed tests is failing, though:

==== bind-27.2 button names FAILED
==== Contents of test case:

    bind .t <Button-@> foo

---- Result was:
bad event type or keysym "@"
---- Result should have been (exact matching):
specified keysym "@" for non-key event
==== bind-27.2 FAILED

A number of unrelated tests are failing as well.  Is that somehow expected?

...
Tests ended at Tue Mar 22 09:03:47 CET 2016
all.tcl:        Total   9353    Passed  8243    Skipped 1049    Failed  61
Sourced 91 Test Files.
Files with failing tests: bind.test canvText.test focus.test font.test grid.test scrollbar.test textDisp.test textWind.test unixFont.test unixWm.test winfo.test


Harald, I feel honored by your words, thank you very much!  I would definitely be interested in getting more involved in Tk, although, as with BWidgets, I would most definitely need guidance at the start.  Do you have any idea how should I proceed?

Thank you!

jan.nijtmans added on 2016-03-14 14:13:30:

Adrián, please try [56355af1f8411fff]. I see no problem supporting buttons up to '9', as long as the test-suite shows that it doesn't cause regressions. It looks fine to me. New (trivial) test-cases added and documentation modified as well.

Please provide feedback if this works for you, then I'll merge to trunk.


fvogel added on 2016-03-11 15:30:43:
I have no particular opinion on this suggestion, only that I have no power to grant any rights.

oehhar added on 2016-03-11 10:00:38:

Perhaps it is wise to grand commit rights to Adriàn.

He is actively committing to BWidget and I can recomment him.

-Harald


fvogel added on 2016-03-11 08:34:02:
The patch looks very simple, but I cannot try it since I don't have a mouse with enough buttons!

Would you mind to create a few new test cases that we could insert in the existing test suite, so that we cover the new functionality?

Also the documentation should be updated by the patch. Currently the man page for bind explicitely states that mouse buttons are 1-5.

Can you take care of all this and provide an updated patch? Thanks!