You are here: Surpac Concepts > Macros > SCL > GUIDO > GuidoMenuItem
GEOVIA Surpac

GuidoMenuItem

Overview

A GuidoMenuItem is used in GuidoMenuBars and GuidoPopupMenu to provide an action button to do some assigned task. When the menu item is selected with the mouse it causes an action to take place which may be to run an internal Surpac command or execute a Tcl procedure.

Synopsis

GuidoMenuItem Name Body

Description

The GuidoMenuItem 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 with the mouse or space bar on the keyboard when it has focus.

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 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.

The command can take one of three types as follows:

  • server - execute a command on the server
  • client - execute a command on the client
  • script - run a tcl script
The function depends upon the type of command. It will either be the name of a server function, the name of a client function, or the pathname to a Tcl script.
-command server "CLEAR GRAPHICS"
-command client "TOGGLE MESSAGE LOG"
-command script "MACROS:grade_control.tcl"

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 GuidoMenuItems that simply print a message to the message window. See example 2 of GuidoTree for a more realistic example.

# GuidoMenuItem Example 1
set formDef {
  GuidoPopupMenu myMenu {
    GuidoMenuItem add {
      -label "New"
      -action mouseReleased {[puts "The add menu item was pressed"]}
    }
    GuidoMenuItem rename {
      -label "Rename"
      -action mouseReleased {[puts "The rename menu item was pressed"]}
    }
    GuidoMenuItem delete {
      -label "Delete"
      -action mouseReleased {[puts "The delete menu item was pressed"]}
    }
    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