menuitem

A menuItem is used to place a pickable item in the right-click menu. The syntax for a menuItem is:

menuItem <name> <label> [checked:<boolean>] [enabled:<boolean>] [filter:<function>]

Parameters

name:

Used to refer to when writing an event handler.

label:

The string that appears in the right-click menu.

checked:

Specifies if a check mark appears before the label in the right-click menu. If true the item is checked, otherwise the item is unchecked.

enabled:

Specifies if the item is enabled for interaction when the right-click menu is opened. If true the item is enabled, otherwise the item is disabled and appears unavailable.

filter:

A function that returns a Boolean value. The filter function is evaluated when the right-click menu is first opened. If the filter function returns true the menuItem appears in the menu, otherwise it is not displayed.

Properties

<menuitem>.text String

The string that appears in the right-click menu.

<menuitem>.checked Boolean

Specifies if a check-mark appears before the label in the right-click menu. If true the item is checked, otherwise the item is unchecked.

<menuitem>.enabled Boolean

Specifies if the item is enabled for interaction when the right-click menu is opened. If true the item is enabled, otherwise the item is disabled and appears as unavailable.

Events

on <menuitem> picked do <expr>

Called when the user clicks the menu item.

EXAMPLE:

   rcmenu RCmenuRenderable
   (
   fn onlyOneSelected = selection.count == 1 -- define filter function
   menuItem mi_r "Renderable" filter: onlyOneSelected -- display if only 1 object selected
   on RCmenuRenderable open do -- perform following on rcmenu open
   (
   if selection.count == 1 then -- if only one object selected...
   (
   mi_r.text = $.name + " | " + "Renderable" -- change text of menu item
   if isKindOf $ Shape then -- if shape set renderable property to
   $.renderable=$.renderable -- itself to get shape and node renderable
   -- properties the same
   mi_r.checked=$.renderable -- turn on menu item check if renderable
   )
   )
   on mi_r picked do$.renderable = not $.renderable -- when menu item picked, flip renderable value
   )
   --
   registerRightClickMenu RcmenuRenderable -- register the rcmenu