| Ticket UUID: | 680660 | |||
| Title: | Menu items accidentally selected | |||
| Type: | Bug | Version: | obsolete: 8.4.1, 8.6.18, 9.0.5, 9.1b1 | |
| Submitter: | djarseneau | Created on: | 2003-02-05 03:43:08 | |
| Subsystem: | 01. Bindings | Assigned To: | aku | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2026-09-30 20:31:45 | |
| Resolution: | Fixed | Closed By: | nemethi | |
| Closed on: | 2026-09-30 20:31:45 | |||
| Description: |
The bindings for menubuttons/menus allow mouse
selection by
either press-drag-release or by click-move-click, and
both
normally work fine. However, when the menu is posted
so it
overlaps the menubutton, the click-move-click scheme
fails
because some random menu item receives the
ButtonRelease
from the initial click on the menubutton, and gets
selected
immediately.
I have included a demo, if that is of any use. Try
clicking on
the menu button with the window positioned mear the
bottom
of the computer screen.
This behavior occurs on Linux installations of Tcl 8.0
- 8.4.1
(at least). I suspect the problem does not occur on
Windows.
I think the bindings for menus should not accept a
ButtonRelease
for some short period after the menu is posted. The
short period
is probably specified by the window manager settings as
the
button-click time.
As a work-around, I have been using:
bind Menubutton <Button-1> {+
bind [winfo children %W] <ButtonRelease-1> {break}
after 300 { bind [winfo children %W]
<ButtonRelease-1> {}}
}
to disable the ButtonRelease event in menus for the
first 300ms
after the MenuButton is clicked on.
| |||
| User Comments: |
nemethi (claiming to be Csaba Nemethi) added on 2026-09-30 20:31:45:
Serhiy, many thanks! The fix is now in main, core-9-0-branch, and core-8-6-branch; see commits [0f866663], [5c47ae3e], and [3aacabb1]. serhiy.storchaka added on 2026-09-30 08:46:22: The same problem as [470331]. Proposed fix in branch menu-post-under-pointer: the release of the click which posted the menu over the menubutton is ignored while the pointer has not moved, for menubutton and ttk::menubutton. A menu which does not fit below the menubutton is posted above it, or beside the pointer. See [470331] for details. djarseneau added on 2005-05-28 11:48:40: File Added - 136286: menubug2.tcl djarseneau added on 2005-05-28 11:48:39: Logged In: YES user_id=611156 Indeed, the the change of '-direction' goes a long way to relieving this problem. It makes it much less likely for a menu to overlay its menubutton and receive the end-of-click ButtonRelease. I've modified the test case by adding several dwarves to the dwarfs menu. Now it should fail when the window is in the middle of the screen, but succeed when at the top or bottom (but depending on the screen size). I do feel that the overlap, by itself, is not wrong, even though the bug can be fixed by either preventing overlap or by delaying the bindings. It is the blind acceptance of any ButtonRelease, even when it is part of the initial short 'click' that is conceptually wrong. jenglish added on 2005-05-27 05:29:17: Logged In: YES user_id=68433 The attached test case appears to be out-of-date -- following the instructions in the label (move the window to the bottom of the screen and click on the menubutton), in Tk 8.4.9 the menu is posted above the menubutton, not on top of it. (The menubutton in effect switches from '-direction below' to '-direction above' if '-direction below' would place the menu offscreen). Don't know if the underlying problem is still present, but the test case doesn't seem to trigger it anymore. djarseneau added on 2003-02-06 09:18:58: File Added - 41628: menubug.tcl | |||
Attachments:
- menubug2.tcl [download] added by djarseneau on 2005-05-28 11:48:39. [details]
- menubug.tcl [download] added by djarseneau on 2003-02-06 09:18:58. [details]
