Tk Source Code

View Ticket
Login
2026-10-31
20:30 • Closed ticket [2903b4c9]: Undocumented constraints on menubars plus 7 other changes artifact: 45a0693a user: nemethi
19:34
Fix [2903b4]: Toplevel lost its menubar when the menubar clone was destroyed check-in: 389e0875 user: csaba tags: core-8-6-branch
2026-10-29
17:14
Fix [2903b4]: Toplevel lost its menubar when the menubar clone was destroyed check-in: b5da3af6 user: jan.nijtmans tags: core-9-0-branch
17:04
Fix [2903b4]: Toplevel lost its menubar when the menubar clone was destroyed check-in: 5b1e8d51 user: jan.nijtmans tags: trunk, main
2026-10-11
13:10 • Ticket [2903b4c9] Undocumented constraints on menubars status still Open with 3 other changes artifact: 5bab0f26 user: serhiy.storchaka
13:10
Fix [2903b4c9ab]: a toplevel lost its menubar when the menubar clone was destroyed, e.g. together with the other children of the toplevel, and setting -menu to the same menu did not create the clone again. Set the menubar again if its clone is missing. Test menu-25.17. closed check-in: 7d68f657 user: serhiy.storchaka tags: menubar-clone-recreate
2025-03-21
21:00 • Add attachment killChildFrame.tcl to ticket [2903b4c9] artifact: e3bdde9f user: marc_culler
20:55 • New ticket [2903b4c9] Undocumented constraints on menubars. artifact: 6d17cf4e user: marc_culler

Ticket UUID: 2903b4c9ab53fd5504a3824e14b46b7eb2c223c4
Title: Undocumented constraints on menubars
Type: Bug Version: 9.1
Submitter: marc_culler Created on: 2025-03-21 20:55:47
Subsystem: 10. Generic Menus Assigned To: nobody
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2026-10-31 20:30:16
Resolution: Fixed Closed By: nemethi
    Closed on: 2026-10-31 20:30:16
Description:
If you "read the source, Luke" you will find three constraints on menus and
menubars discussed in the comments of generic/tkMenu.c.  None of these are
mentioned in the documentation.

* In order to make the bindings for cascade menus work properly under Unix,
  the cascade menus' pathnames must be proper children of the menu that they
  are cascade from.

* Another constraint is that the menus used for menubars must be children
  of the toplevel widget that they are attached to.

* And on the Macintosh, the platform specific menu handle for cascades
  attached to a menu bar must have a title that matches the label for the
  cascade menu.

I believe that the third constraint is handled automatically,
so there is no need for it to be mentioned in the documentation.

However, Nicolas Bats has provided a script which demonstrates that not
following the second constraint breaks the menubars on macOS.  I will
attach his script.
User Comments: nemethi (claiming to be Csaba Nemethi) added on 2026-10-31 20:30:16:

Merged by Jan into main and core-9-0-branch by commits [5b1e8d51] and [b5da3af6 ]. Backported to core-8-6-branch by commit [389e0875]. Closing the ticket.


serhiy.storchaka added on 2026-10-11 13:10:39:

The menubar breaks because the script destroys all children of the toplevel, including the menubar clone .tl.#menuBar, and setting -menu to the same value did not create the clone again. This happens on X11 too, and the menubar does not need to be a child of the toplevel. Proposed fix in branch menubar-clone-recreate, test menu-25.17.


Attachments: