class Command

Parent: Object | Class Index
Methods: new, large_icon=, menu_text=, set_validation_proc, small_icon=, status_bar_text=, tooltip= |
Sample Code:commandtests.rb |

The Command class is the preferred class for adding tools to the menus and Ruby toolbars.

Class Methods

new
The new method is used to create a new command.
Syntax:
command = UI::Command.new "menutext" { ...}
Arguments:
"menutext" - the text that will appear for this command's menu item if it appears on a menu ... - code that executes the command when the menu item or toolbar item is selected
Return Value:
command - the new Command object
Comments:
Example:
add_separator_to_menu("Draw") # Adds a Test submenu to the Draw menu where the Tester menu item appears testmenu = UI.menu("Draw").add_submenu($tStrings.GetString("Test")) # This menu item simply displays Hello World on the screen when clicked cmd = UI::Command.new($tStrings.GetString("Tester")) { helloWorld } testmenu.add_item cmd

Instance Methods

large_icon=
The large_icon= method is used to identify the icon file for the command's large icon.
Syntax:
command = command.large_icon = path
Arguments:
path - the path to the large icon
Return Value:
command - the Command object
Comments:
Example:
toolbar = UI::Toolbar.new "Test" # This toolbar tool simply displays Hello World on the screen when clicked cmd = UI::Command.new($tStrings.GetString("Test")) { helloWorld } cmd.small_icon = "ToolPencilSmall.png" cmd.large_icon = "ToolPencilLarge.png" toolbar = toolbar.add_item cmd toolbar.show

menu_text=
The menu_text= method is used to set the menu item name for the command
Syntax:
command = command.menu_text= "menuitem"
Arguments:
"menuitem" - a string representing the menu item for the command
Return Value:
command - a Command object
Comments:
Example:
add_separator_to_menu("Draw") # Adds a Test submenu to the Draw menu where the Tester menu item appears testmenu = UI.menu("Draw").add_submenu($tStrings.GetString("Test")) # This menu item simply displays Hello World on the screen when clicked cmd = UI::Command.new($tStrings.GetString("Tester")) { helloWorld } cmd = cmd.menu_text = "New String" testmenu.add_item cmd

set_validation_proc
The set_validation_proc method is used to
Syntax:
Arguments:
Return Value:
Comments:
Example:

small_icon=
The small_icon= method is used to identify the icon file for the command's small icon.
Syntax:
command = command.small_icon= path
Arguments:
command = command.large_icon= path
Return Value:
command - the Command object
Comments:
Example:
toolbar = UI::Toolbar.new "Test" # This toolbar tool simply displays Hello World on the screen when clicked cmd = UI::Command.new($tStrings.GetString("Tester")) { helloWorld } cmd.small_icon = "ToolPencilSmall.png" cmd.large_icon = "ToolPencilLarge.png" toolbar = toolbar.add_item cmd toolbar.show

status_bar_text=
The status_bar_text= method is used to set the status bar text for the command.
Syntax:
command = command.status_bar_text= "text"
Arguments:
"text" - the text that will appear on the status bar when the cursor is over the command's menu item
Return Value:
Comments:
Example:
toolbar = UI::Toolbar.new "Test" # This toolbar tool simply displays Hello World on the screen when clicked cmd = UI::Command.new($tStrings.GetString("Tester")) { helloWorld } cmd.small_icon = "ToolPencilSmall.png" cmd.large_icon = "ToolPencilLarge.png" cmd.status_bar_text = $tStrings.GetString("Testing the toolbars class") toolbar = toolbar.add_item cmd toolbar.show

tooltip=
The tooltip= method is used to set the tooltip for the command's icon.
Syntax:
command = command.tooltip= "tooltip"
Arguments:
"tooltip" - the text that appears when the cursor is over the command's icons
Return Value:
command - a Command object
Comments:
Example:
toolbar = UI::Toolbar.new "Test" # This toolbar tool simply displays Hello World on the screen when clicked cmd = UI::Command.new($tStrings.GetString("Tester")) { helloWorld } cmd.small_icon = "ToolPencilSmall.png" cmd.large_icon = "ToolPencilLarge.png" cmd.tooltip = $tStrings.GetString("Test Toolbars") toolbar = toolbar.add_item cmd toolbar.show