Tk Source Code

View Ticket
Login
Ticket UUID: 835832
Title: tearoff menu add's should return index
Type: RFE Version: None
Submitter: davidw Created on: 2003-11-04 16:38:01
Subsystem: 10. Generic Menus Assigned To: hobbs
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2026-10-22 17:22:37
Resolution: Fixed Closed By: serhiy.storchaka
    Closed on: 2026-10-03 21:03:02
Description:
When I have code like this, I would like to be able to
store the index number of particular options for later use.

    menu .mbar
    . config -menu .mbar

    .mbar add cascade -label "File" -underline 0 \
-menu [menu .mbar.file -tearoff 0]
    .mbar add cascade -label "Help" -underline 0 \
-menu [menu .mbar.help -tearoff 0]

    set m .mbar.file
    $m add command -label "Open Test Suite" -underline 0 \
-command gui::opentestsuite

This simple patch does what I need.  There is probably
extra work/thinking to do to make sure that everything
is consistent...
User Comments: serhiy.storchaka added on 2026-10-03 21:03:02:

Implemented by TIP #658 in Tk 9.0 ([e2b00bfd29]): add and insert return the id of the new entry, which can be used as an index.


dkf added on 2005-01-12 16:34:31:
Logged In: YES 
user_id=79902

Seems like a good idea to me (the index won't necessarily be
valid if you change the -tearoff option or insert new
entries, but that's easily resolvable using careful
documentation)

Needs microTIP.

davidw added on 2003-11-04 23:38:07:

File Added - 66429: menupatch.diff

Attachments: