| Ticket UUID: | 8f73af092a6474754776d258f4ff41f1dbc832e2 | ||||||||||||||||||
| Title: | Tk 9: %b reports the X11 button number, not the TIP 474 number (Back button matches <Button-4>, but %b is 8) | ||||||||||||||||||
| Type: | Bug | Version: | 9.0.5, 9.1 | ||||||||||||||||
| Submitter: | serhiy.storchaka | Created on: | 2026-10-06 19:20:25 | ||||||||||||||||
| Subsystem: | 01. Bindings | Assigned To: | jan.nijtmans | ||||||||||||||||
| Priority: | 5 Medium | Severity: | Minor | ||||||||||||||||
| Status: | Closed | Last Modified: | 2026-10-06 22:49:46 | ||||||||||||||||
| Resolution: | Fixed | Closed By: | jan.nijtmans | ||||||||||||||||
| Closed on: | 2026-10-06 22:49:46 | ||||||||||||||||||
| Description: |
TIP 474 renumbered the mouse buttons for scripts: "buttons 4 up to 9 in scripts will handle the X11 buttons numbered 8 up to 13". Binding patterns and
pack [frame .f -width 200 -height 100]
bind .f <Button-4> {puts "<Button-4> %b"}
bind .f <Button-8> {puts "<Button-8> %b"}
bind .f <ButtonPress> {puts "<ButtonPress> %b"}
# Then press the mouse's Back button over the frame, and:
event generate .f <ButtonPress> -button 4
event generate .f <ButtonPress> -button 8
(Tk 8.6 refuses to bind <Button-8>: "bad button number". Forward behaves the same with 5/9. On Windows the Tk 9 build was 9.1.) Expected in Tk 9: <Button-4> 4 in the first three rows, and <Button-8> 8 in the last. The pattern side adds 4 (GetButtonNumber in generic/tkBind.c, and -button in HandleEventGenerate), and printing a pattern subtracts it again (tkBind.c:5220), but the %b case (tkBind.c:3025) prints xbutton.button unchanged. Applying the same mapping there, (button > 7) ? button - 4 : button, would make %b agree with the patterns, and restore the Tk 8.6 values on Windows. bind.n still says only "the number of a button (1-9)"; it could say that 4 and 5 are the side buttons and that 4-7 of X11 are the wheel. | ||||||||||||||||||
| User Comments: |
jan.nijtmans added on 2026-10-06 22:49:46:
Tests and documentation fixes would be a very welcome addition! serhiy.storchaka added on 2026-10-06 20:42:15: Thank you for the fantastically quick fix, Jan! Are the documentation changes and tests needed? jan.nijtmans added on 2026-10-06 20:01:27: Fixed in [b310da761bbab679|trunk] and core-9-0-branch. Well done! | ||||||||||||||||||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki