Tk Source Code

View Ticket
Login
2026-11-04
11:51 • Closed ticket [65e299ac]: X11: a cascade menu near the right edge of the screen is posted over its parent menu plus 9 other changes artifact: 3139a5c2 user: nemethi
2026-09-30
20:44 • Closed ticket [4e7fbe8b]: X11: menus taller than the screen cannot be scrolled plus 9 other changes artifact: f6dc1835 user: nemethi
20:25 • Closed ticket [470331ff]: Displaced Menus do not stay open. plus 5 other changes artifact: 98d37f71 user: nemethi
20:24 • Ticket [470331ff]: 8 changes artifact: 15b067af user: nemethi
19:56
Fix for [470331ffff]: Displaced menus do not stay open; [680660ffff]: Menu items accidentally selected; [1596662fff]: Menu behaviour at screen bottom; [f9d316a5e0]: Linux menu problem if menu near the bottom of screen. check-in: 3aacabb1 user: csaba tags: core-8-6-branch
18:10
Fix for [470331ffff]: Displaced menus do not stay open; [680660ffff]: Menu items accidentally selected; [1596662fff]: Menu behaviour at screen bottom; [f9d316a5e0]: Linux menu problem if menu near the bottom of screen. check-in: 5c47ae3e user: csaba tags: core-9-0-branch
16:26
Fix for [470331ffff]: Displaced menus do not stay open; [680660ffff]: Menu items accidentally selected; [1596662fff]: Menu behaviour at screen bottom; [f9d316a5e0]: Linux menu problem if menu near the bottom of screen; [4e7fbe8b4a]: X11: menus taller than the screen cannot be scrolled. check-in: 0f866663 user: csaba tags: trunk, main
09:52 • Ticket [4e7fbe8b] X11: menus taller than the screen cannot be scrolled status still Open with 3 other changes artifact: 8b18030f user: serhiy.storchaka
08:46 • Ticket [f9d316a5] linux menu problem if menu near the bottom of screen status still Open with 4 other changes artifact: 0627b5ef user: serhiy.storchaka
08:46 • Ticket [1596662f] Menu behaviour at screen bottom status still Open with 4 other changes artifact: a5cbdcd9 user: serhiy.storchaka
08:46 • Ticket [680660ff] Menu items accidentally selected status still Open with 4 other changes artifact: f32de081 user: serhiy.storchaka
08:44 • Ticket [470331ff] Displaced Menus do not stay open. status still Open with 4 other changes artifact: 2f1dc6a4 user: serhiy.storchaka
2026-09-29
20:40
Fix [470331], [680660], [1596662fff], [f9d316a5e0]: a menu posted over its menubutton or menubar entry invoked the entry under the pointer on the release of the click which posted it. Post the menu of a menubar entry or a menubutton above it if it does not fit below, or aside of the pointer if it fits neither below nor above. Ignore the release of the click which posted a menu if the pointer is over another menu and has not moved. check-in: c8129022 user: serhiy.storchaka tags: menu-post-under-pointer
2008-08-19
09:44 • Ticket [470331ff] Displaced Menus do not stay open. status still Open with 2 other changes artifact: 49da00ed user: tmh
09:44 • Ticket [470331ff]: 4 changes artifact: 783a1e7d user: tmh
2001-10-11
18:15 • New ticket [470331ff]. artifact: 8e37ce1a user: randolf

Ticket UUID: 470331
Title: Displaced Menus do not stay open.
Type: Bug Version: obsolete: 8.5.4, 8.6.18, 9.0.5, 9.1b1
Submitter: randolf Created on: 2001-10-11 18:15:43
Subsystem: 12. Unix Menus Assigned To: aku
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-09-30 20:25:49
Resolution: Fixed Closed By: nemethi
    Closed on: 2026-09-30 20:25:49
Description:
When
a) a menubutton is near the lower edge of the screen
b) the user tries to open the menu with a simple click
   (and immediately releases the mouse button)
c) the menu is too long to be displayed in full
length     on the remaining screen space and is
displaced:

the menu will immediately disappear again, selecting
an entry that is under the mouse pointer after
displacement. The user has no chance to select, nor
does he even see what he selected. Anything including
some really evil things like deleting files etc. can
happen.

Expected behaviour:
The menu should simply stay open as it is doing
when it does not need to be displaced.

Note: On Windows this works as expected!
No test has been performed on the Mac.
Xaw(3D) does it wrong too, Motif/GTK do it right
but displace in a different way.

Sample Script:
Run it. Place the window on the lower edge of your
screen. Do a single click on "File". The application
quits unexpectedly...

-snip-
# Create a menubar 
# 
menu .mb -type menubar 
. config -menu .mb 
.mb add cascade -label File -underline 0 -menu .mb.file 
menu .mb.file -tearoff 0 
.mb.file add command -label Exit -command exit 
.mb.file add command -label Exit -command exit 
.mb.file add command -label Exit -command exit 
.mb.file add command -label Exit -command exit 
.mb.file add command -label Exit -command exit 
.mb.file add command -label Exit -command exit 
.mb.file add command -label Exit -command exit 
.mb.file add command -label Exit -command exit 
.mb.file add command -label Exit -command exit 
.mb.file add command -label Exit -command exit 
.mb.file add command -label Exit -command exit 

frame .f -width 200 -height 100 
pack .f -side top -fill both -expand 1 
update 
-snap-
User Comments: nemethi (claiming to be Csaba Nemethi) added on 2026-09-30 20:24:16:

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:44:23:

Still present in 8.6 and 9.x on X11. The same problem is reported in [680660], [1596662] and [f9d316a5e0]. If a menu does not fit below its menubar entry or menubutton, it is moved up over the entry. The release of the click which posted it then invokes the entry under the pointer. The same happens with tk_popup near the bottom or right edge of the screen.

I implemented a fix in two parts, similar to other toolkits:

  1. A menu is posted above the menubar entry or menubutton if it does not fit below it but fits above it. A menubutton menu which fits neither below nor above is posted beside the pointer. tk_popup posts the menu to the left of and/or above the point if it does not fit to the right of or below it.
  2. If the menu is still under the pointer (for example, it is larger than the screen, or it is an option menu), the release of the click which posted it is ignored while the pointer has not moved, and the entry under the pointer is not highlighted. A menu larger than the screen should rather be limited to the screen and scrolled, as in other toolkits; see [4e7fbe8b4a].

The new demo "Popup (context) menus" shows this with tk_popup and menus of different sizes. Menus posted from a menubar or a menubutton behave similarly, but it is easiest to see with popup menus.


tmh added on 2008-08-19 09:44:03:
Logged In: YES 
user_id=92123
Originator: NO

The included script behaves the same with Tk 8.5.4 and Tk 8.6 on my test system.
I'm not convinced that this is a bug however, though I agree it is annoying.

When the posted menu is too near the bottom of the screen.  Selecting the Menu causes one of the menu items to appear under the cursor.  Simply releasing the mouse button causes that menu item to be executed.  If one moves the mouse pointer off of the menu list item.  The button can be released without invoking anything and in fact the menu paints.  Correcting this would require changing the 'X' location of the menu as well as adjusting the Y to fit the menu on the screen.