GuidoCheckBoxMenuItem
Overview
A GuidoCheckBoxMenuItem is used in GuidoMenuBars and GuidoPopupMenu to provide an action item that has two possible states. When the menu item is selected / deselected with the mouse or keyboard it causes an action to take place which may be to run an internal Surpac command, execute a Tcl procedure, or set a status variable.
Synopsis
GuidoCheckBoxMenuItem Name Body
Description
The GuidoCheckBoxMenuItem command when processed will define a small rectangular region on the menu that will contain a text caption and/or icon. It may be selected and deselected with the mouse or space bar on the keyboard when it has focus. When the item is selected a small tick will appear at the front of the menu item.
Arguments
Name Name is a unique identifier that you assign and is used to differentiate this object from other Guido objects in the menu definition.
Body The body of the check box menu item may contain a number of switches to modify the default behaviour. The body begins with an opening curly brace and ends with a closing curly brace. If there is no required body the curly braces {} are required as a place holder for this argument.
Switches The following switches can be used to modify the default behaviour of the menu item:
| -label text | The -label switch allows you to specify the text that
appears inside the menu item
-label "Edit" -label "Delete" |
| -icon pathname | The -icon switch allows you to insert a gif/jpg/png
image icon into the menu item for display. The pathname is relative to
the standard SSI_RESOURCES: logical (normally set to /ssi_V?.??/share/resource/)
-icon my_icons/edit.gif |
| -command type function | The -command switch sets the menu item to perform
some action. Do not use this switch to attach a Guido (form) procedure
to the menu item, use an action callback method instead.
On a check box menu item normally two -command switches are specified. The first switch specifies the command for the selected state and the second one for the deselected state. The command can take one of three types as follows:
-command server "CLEAR GRAPHICS" -command client "TOGGLE MESSAGE LOG" -command script "MACROS:grade_control.tcl" |
| -selected_value value | The -selected_value switch sets the value that will
be assigned to the check box menu item when it is selected.
-selected_value "yes" -selected_value "on" |
| -unselected_value value | The -unselected_value switch sets the value that will
be assigned to the check box menu item when it is unselected.
-selected_value "no" -selected_value "off" |
Common Guido switches reference
Examples
Example 1
The example form below contains a button that will invoke a popup menu. The popup menu contains a number of GuidoCheckBoxMenuItems that simply print a message regarding the state of the selection to the message window.
# GuidoCheckBoxMenuItem Example 1
set formDef {
proc displayState {item} {
set state [$item getCurrentValue]
set name [$item getName]
puts "$name are $state"
}
GuidoPopupMenu myMenu {
GuidoCheckBoxMenuItem faces {
-label "Faces"
-selected_value "on"
-unselected_value "off"
-action mouseReleased {[displayState $faces]}
}
GuidoCheckBoxMenuItem edges {
-label "Edges"
-selected_value "on"
-unselected_value "off"
-action mouseReleased {[displayState $edges]}
}
GuidoCheckBoxMenuItem lights {
-label "Lights"
-selected_value "on"
-unselected_value "off"
-action mouseReleased {[displayState $lights]}
}
GuidoSeparator sep {}
GuidoMenuItem exit {
-label "Exit"
-action mouseReleased {[$myMenu setVisible false]}
}
}
GuidoForm form {
-label "Using Menu Components"
-default_buttons
-layout BoxLayout Y_AXIS
GuidoFiller fil1 {
-height 1
}
GuidoButton button {
-caption "Press for Popup menu"
-width 25
-action valueChanged {[$myMenu setVisible true]}
}
GuidoFiller fil1 {
-height 1
}
}
}
# Create and run the form
SclCreateGuidoForm formHandle $formDef {}
$formHandle SclRun {}
|
See Also
Guido
GuidoForm
Common guido switches
GuidoButtonGroup
GuidoCheckBoxMenuItem
GuidoMenuItem
GuidoRadioButtonMenuItem
GuidoSeparator
GuidoMenu
GuidoMenuBar
GuidoPopupMenu
Guido action events and callbacks