Menu Plug-In Structs

The Structs returned by getGlobalMenuOptions and getEditorMenuOptions have a defined structure.

A menu Struct has one or more option members, each containing the following members:

  • label—text to display in the menu.
  • component—name of the component that implements the callback operation
  • operation—name of the callback operation to activate when the option is clicked
  • enabled—a Boolean (with possible values 1|0) that indicates whether the option is enabled or not, in which case it is dimmed.

It is possible to specify a separator between menu options by defining a menu option with only a label with the value _sep_. This separator is displayed only if another option follows in the runtime menu. This ensures that if an option is not displayed (for example, it is applicable to a different type of object), that no empty section is displayed.

For example:

[menu]
  [option]
    [label] = "Option 1"
    [component] = "MY_CPT"
    [operation] = "doOption1"
    [enabled] = 1
  [option]
    [label] = "_sep_"
  [option]
    [label] = "Option 2"
    [component] = "MY_CPT"
    [operation] = "doOption2"
    [enabled] = 0

Example: Building a menu option struct

The following entry builds the Struct for a single user-defined menu option. For more information, see Structs.

entry addOption
  params
    struct pMenu:  in
    string pLabel: in
    string pComponentName: in
    string pCallbackOperation: in
    numeric pEnabled: in
  endparams

  variables
    struct vOption
  endvariables
				
  pMenu->option{-1} = $newstruct  ;- add a new option
  vOption = pMenu->option{-1}
  vOption->label = pLabel
  vOption->component = pComponentName
  vOption->operation = pCallbackOperation
  vOption->enabled = pEnabled
				
  return 0
end ;- entry addOption

This can be called by the getGlobalMenuOptions and getEditorMenuOptions operations to build up menu Struct that may contain multiple user-defined options. For example:

pMenu->$name = "menu"
call addOption(pMenu, "Option 1", "MY_CPT", "doOption1", 1)
call addOption(pMenu, "Option 2", "MY_CPT", "doOption2", 0)