menuItem

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

menuItem checked: ] [ enabled: ] [ filter: ]

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

.text String

The string that appears in the right-click menu.

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

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

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

See also

RCMenu Clauses

Scripted Right-Click Menus