3.7.5.42 Menu


LabTalk Object Type:

Utility

The menu object methods and properties are designed for menu manipulation. They are most effective when used together with the menu command. The effects of the menu object methods may not be immediately apparent. It is sometimes necessary to make a different window type active before the result is visible. Alternatively, shrink Origin to an icon, then restore the application.
Note: Menu manipulation requires exact specification of the desired menu bar, menu, and menu commands. For information on how to specify the active menu bar and the active menu, see the menu command.

Properties:

Property Access Description
menu.lastExeID Read only
numeric

Holds the ID number of the most recently executed menu command.

menu.lastID Read only
numeric

Holds the ID number of the most recently created menu command.

menu.level Read/Write
numeric

Gets and sets the menu level for menus created by cnf or omc files. For example, when menu.type=1 (use cnf file created menus), set menu.level = 2 is to choose the second menu in cnf file created menus group as active menu.

menu.level$ Read/Write
string

Read and set Menu level by menu name defined in cnf file or by *.omc file name. For instance, menu.level$ = ; will read the name of current active menu in cnf file or omc files created menus group.

menu.type Read/Write
numeric

Read and set Menu type. There are two menu types: 1 = menus from customized cnf file (eg. build-in Full Menus, Short Menus), 2 = menus from omc files.


Methods:

Method Description
menu.check(ID, num)

This method will only work for user-created menu commands. If num = 1, place a check mark next to the menu command with the specified menu ID. If num = 0, uncheck the menu command.

menu.cleanup( )

Remove all menu modifications, including those made in configuration files. To recover configuration file modifications, select an option from Preference:Menu.

menu.gray(ID, num)

Not currently implemented.

menu.itemDel(pos)

Delete the menu command at the specified pos position in the active menu.

menu.itemDelBelow(pos)

Delete the menu command at the specified pos position, and all the menu commands below it, from the active menu.

menu.rename(ID, name)

This method will only work for user-created menu commands. Rename the menu command with the specified menu ID to the specified name.

Examples:

This script deletes the Copy menu command and all menu commands below it in the Edit menu.

 Menu -w;   //make the Worksheet menu bar active
menu ?Ed;   //make the Edit menu active
menu.itemDelBelow(4);

This script creates a new menu command at the end of the Edit menu.

 Menu -P;   //make the Layout menu bar active
menu ?Ed;   //make the Edit menu active
Menu (My List) {type -b "my list";};   
// append My List menu command to the end of the Edit menu

This script finds the ID of the most recently created menu command, and then executes the menu command.

MyId = menu.lastid;   
// set the value of myID to the ID of the last menu command
menu -e myId; 
// execute the menu command with ID 'myId'