class Menu

Parent: Object | Class Index
Methods:add_item, add_separator, add_submenu, set_validation_proc |
Sample Code:menutests.rb |

An interface to a menu.

Instance Methods

add_item
The add_item menu item is used to add a menu item to the specified menu.
Syntax:
item_id = menu.add_item "menu" { procedure }
Arguments:
"menu" - a string name of the menu to add procedure - a method that will be invoked when the menu item is selected
Return Value:
item_id - a unique numerical item id for the menu
Comments:
This method takes a block that defines the action to perform when the menu item is selected. menu.add_item("Compute Area") { compute_area_function } The item id that is returned can be used when adding an optional validation procedure for the menu item.
Example:
plugins_menu = UI.menu("Plugins") item = plugins_menu.add_item("Test") { test } if (item) UI.messagebox item else UI.messagebox "Failure" end

add_separator
The add_separator method is used to add a menu separator to a menu.
Syntax:
menu.add_separator
Arguments:
Return Value:
Comments:
Example:
plugins_menu = UI.menu("Plugins") plugins_menu.add_separator

add_submenu
The add_submenu method is used to add a sub-menu to a menu.
Syntax:
submenu = menu.add_submenu "submenu_name"
Arguments:
Return Value:
submenu - a Menu object
Comments:
Example:
plugins_menu = UI.menu("Plugins") submenu = plugins_menu.add_submenu("Test") if (submenu) UI.messagebox submenu else UI.messagebox "Failure" end

set_validation_proc
The set_validation_proc method is used to identify the menu validation procedure.
Syntax:
status = menu.set_validation_proc item_id {...}
Arguments:
Return Value:
status = true if successful, false if unsuccessful
Comments:
Example:
plugins_menu = UI.menu("Plugins") item = plugins_menu.add_item("Test") { test } UI.messagebox item begin status = plugins_menu.set_validation_proc(item) { testProc } rescue UI.messagebox $!.message end