Tk Source Code

View Ticket
Login
Ticket UUID: 65e299ace5a62c81cd75bbfb42709758a96877c1
Title: X11: a cascade menu near the right edge of the screen is posted over its parent menu
Type: Bug Version: 8.6.18, 9.0.5, 9.1.0
Submitter: serhiy.storchaka Created on: 2026-09-30 17:31:37
Subsystem: 12. Unix Menus Assigned To: aku
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-11-04 11:51:43
Resolution: Fixed Closed By: nemethi
    Closed on: 2026-11-04 11:51:43
Description:

If a cascade menu does not fit to the right of its parent menu, it is shifted left onto the screen, over its parent menu. It covers the parent menu, including the pointer on the cascade entry, so the other entries of the parent menu cannot be reached with the mouse, and the release of a press-drag-release invokes the entry of the cascade menu under the pointer. The fix for [470331] does not help here: it ignores the release only if the pointer has not moved since the press which posted the menu.

menu .m -tearoff 0
.m add cascade -label "Cascade entry" -menu .m.c
menu .m.c -tearoff 0
for {set i 0} {$i < 5} {incr i} {
    .m add command -label "A rather long entry $i"
    .m.c add command -label "Another long entry $i"
}
.m post [expr {[winfo screenwidth .m] - [winfo reqwidth .m]}] 100
update
.m postcascade 0

Other toolkits (Qt, GTK, WinForms) post the cascade menu to the left of its parent menu if it does not fit to the right of it. GTK 3 also posts the cascades of such a menu to the left.

Proposed fix in branch menu-cascade-flip: a cascade menu which does not fit to the right of its parent menu, but fits to the left of it, is posted to the left of it; its own cascades continue to the left while they fit, and are posted to the right if they do not fit to the left. Tests menuDraw-17.4 to 17.6. The "Cascades" menu of the menu demo has a new "Deep cascade" item to try it near an edge of the screen.

User Comments: nemethi (claiming to be Csaba Nemethi) added on 2026-11-04 11:51:43:

Merged by Jan into main and core-9-0-branch by commits [1b7b8535] and [d4f89751]. Backported to core-8-6-branch by commit [b07e4dde]. Closing the ticket.