Tk Source Code

View Ticket
Login
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: Open Last Modified: 2026-10-11 13:10:39
Resolution: None Closed By: nobody
    Closed on:
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: 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: