Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

menu

Status
Not open for further replies.

akpr

Programmer
Jul 25, 2001
19
US
I created a menu. How do I pass a reference to that menu to another function
i.e. I have a menu as follows
File
new
open
save
I want to disable the Save menu as soon as the menu is clicked.

 
To "pass a reference to [ignore][a][/ignore] menu" just pass the name of the menu widget. Then you can execute any of the menu operations described in the documentation. For example, let's assume that you've created the menu described above as follows:

Code:
. configure -menu .mbar

menu .mbar
.mbar add cascade -label "File"     -underline 0 -menu .mbar.file

menu .mbar.file
.mbar.file add command -label "New"     -underline 0 -command {}
.mbar.file add command -label "Open"     -underline 0 -command {}
.mbar.file add command -label "Save"     -underline 0 -command {}

Now, to programmatically interact with your File menu from elsewhere in your application, simply use execute an operation on your [tt].mbar.file[/tt] widget. For example, to disable your "Save" menu item:

Code:
.mbar.file entryconfigure "Save" -state disabled

To reactivate it:

Code:
.mbar.file entryconfigure "Save" -state normal

To programmatically invoke the "Save" command:

Code:
.mbar.file invoke "Save"
- Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top