*ContextMenuItem()

Right-click on an entity to create a new, user-defined context menu item that launches a Tcl procedure.

Syntax

*ContextMenuItem (var_name, label, path to the TCL script file, TCL procedure, entity type)

Application

HyperGraph.

Inputs

var_name
The variable name of the menu item.
label
The label displayed in the right-click, context menu.
path to the TCL script file
Path to the Tcl script that gets sourced when the menu item is selected.
TCL procedure
Tcl procedure that is executed when a menu item is selected.
Five arguments are passed to this procedure. These are only available when you are in the plot window:
  • Page ID
  • Window ID
  • Entity Type
  • Entity ID
  • Point Number
Each of these arguments is one-based. For Point Number, the value is 0 unless you pick Curve for the entity type argument.
entity type
Entity to which the menu is associated. Possible values for the plot window include:
  • Plot
  • Axis
  • Curve
  • Datum
  • Legend
  • Note
  • Title
An additional value, animation, is available when you are in the animation window.

Context

*BeginDefaults()

*BeginPlotDefaults()

Example

*BeginDefaults() 
    *BeginPlotDefaults() 
       *ContextMenuItem(varname, "Run Script", context_menu.tcl, Main, axis) 
       *ContextMenuItem(varname, "Apply window styles...", {getenv("ALTAIR_HOME") + "/utility/scripts/stylesheets.tcl"}, ::plot::StyleSheet::PostWindow, plot 
    *EndPlotDefaults() 
*EndDefaults()

Please also refer to the following context_menu.tcl example:
proc proc2 {args} {
#puts $args
hwi OpenStack
hwi GetSessionHandle sess
sess GetProjectHandle proj
proj GetPageHandle page [lindex $args 0]
page GetWindowHandle wind [lindex $args 1]
wind GetClientHandle plot
plot SetBackgroundColor 4
plot Draw
hwi CloseStack
}
proc proc1 {args} {
puts $args
hwi OpenStack
hwi GetSessionHandle sess
sess GetProjectHandle proj
proj GetPageHandle page [lindex $args 0]
page GetWindowHandle wind [lindex $args 1]
wind GetClientHandle plot
#puts [plot GetBackgroundColor]
plot GetCurveHandle curve [lindex $args 3]
#puts [curve GetLineColor]
curve SetLineColor 9
plot Draw
hwi CloseStack
}