| Ticket UUID: | 1692755 | |||
| Title: | Focused button widgets invoked on Alt-Space | |||
| Type: | Bug | Version: | obsolete: 8.4.14 | |
| Submitter: | dunkfan | Created on: | 2007-04-02 09:42:20 | |
| Subsystem: | 01. Bindings | Assigned To: | jan.nijtmans | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2026-10-05 07:28:15 | |
| Resolution: | Fixed | Closed By: | jan.nijtmans | |
| Closed on: | 2026-10-04 21:01:14 | |||
| Description: |
On Windows, when an Alt-Space event occurs to show the "Windows system menu", the buttons and checkbuttons (provided they have focus) will see the space and/or Alt key events and are invoked. This trivial script shows the misbehaviour. Alt-Space should never cause the checkbutton to be toggled or the button to be invoked. checkbutton .but1 -text "Do something but not on Alt-Space" button .but2 -text "Do something but not on Alt-Space" -command exit pack .but1 .but2 | |||
| User Comments: |
serhiy.storchaka added on 2026-10-05 07:28:15:
Backported to 8.6 in [539457e78c]. jan.nijtmans added on 2026-10-04 21:01:14: Fixed in [38f35c4e4acd66be|trunk] and core-9-0-branch Many thanks! Closing serhiy.storchaka added on 2026-09-19 11:46:31: <Alt-Key> {# nothing} does not help: a pattern with a specific key (<space>) is preferred to a pattern with only a modifier. Bound <Alt-space> to nothing for buttons, checkbuttons, radiobuttons and their ttk counterparts, so Alt-space only opens the window menu. Fixed in [3f81dcc527] (branch alt-space-no-invoke). alastair_davies added on 2007-04-06 16:40:00: Logged In: YES
user_id=988604
Originator: NO
The problem appears to be that (to quote the manual):
"For a binding to match a given event, the modifiers in the event must include all of those specified in the event pattern. An event may also contain additional modifiers not specified in the binding. For example, if button 1 is pressed while the shift and control keys are down, the pattern <Control-Button-1> will match the event, but <Mod1-Button-1> will not."
In other words, the binding for Button for the <Key-space> event, which invokes the button, will also fire for Alt-space, Control-space, etc.
I notice that when using an Entry, however, no space is inserted into the entry box when Alt-space is pressed. This is because the Entry widget has a general binding for the Alt modifier as follows
% bind Entry <Alt-Key>
# nothing
A similar command added to the bindings for Button solves this problem.
% bind Button <Alt-Key> {# nothing}
| |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki