Interface: CuiDynamicMenu
Example
macroscript MXS_Demo_Action_Item category:"Menu Demo Category" buttonText:"MXS Demo Action Item"
(
-- Defining these two event handlers tells the system that this macroscript should produce a dynamic menu
on populateDynamicMenu menuRoot do
(
-- Generate some custom menu items. Each item has a unique id.
-- Id is passed to dynamicMenuItemSelected when user clicks on menu item.
-- These ids are not visible to the rest of the menu system. They only matter for this specific dynamic menu.
menuRoot.AddItem 1234 "Say Hello in listener" iconName: "Common/Hand" toolTip: "Prints 'Hello' in the Scripting Listener"
menuRoot.AddItem 2345 "Say Goodbye in listener" toolTip: "Prints 'Goodbye' in the Scripting Listener"
menuRoot.addSeparator()
subMenu = menuRoot.addSubMenu "Sub-Menu"
subMenu.AddItem 3456 "Say 3ds Max in listener"
menuRoot.addSeparator()
-- Add existing actions from autobackup action table
local autobackupTableId = -889262067
menuRoot.AddAction autobackupTableId "0"
menuRoot.AddAction autobackupTableId "1"
menuRoot.AddAction autobackupTableId "2"
menuRoot.AddAction autobackupTableId "3" title:"Custom Title"
)
on dynamicMenuItemSelected id do
(
case id of
(
1234: print "Hello"
2345: print "Goodbye"
3456: print "3ds Max"
)
)
)
Properties:
.id : string : Read
Gets the ID for this dynamic menu.
.title : string : Read|Write
Gets the title for this dynamic menu.
.isFlat : boolean : Read|Write
Gets whether this dynamic menu is in flat style.
.parent : Interface : Read
Gets the parent for this dynamic menu.
.menuItems : Interface array : Read
Gets the array of menu items for this dynamic menu.
Methods:
<boolean>Move <guid>parentMenuId beforeId:<guid>
Move - no automatic redraw after invoked
beforeId default value: "00000000-0000-0000-0000-000000000000"
Moves the dynamic menu to the position before the menu specified by beforeId
, in the parent menu specified by parentMenuId
.
<Interface>CreateSubMenu <guid>id <string>title beforeId:<guid>
CreateSubMenu - no automatic redraw after invoked
beforeId default value: "00000000-0000-0000-0000-000000000000"
Creates a new sub menu item with the specified id
and title
, placed before the menu item specified by beforeId
.
<Interface>CreateAction <guid>id <integer>tableId <string>persistentActionId title:<string> beforeId:<guid>
CreateAction - no automatic redraw after invoked
title default value: undefined
beforeId default value: "00000000-0000-0000-0000-000000000000"
Creates a new sub-menu item that calls the specified action item. Returns a CuiActionMenuItem
. The action item is specified by id
and tableId
. The persistentActionId
is a local id unique to this menu assigned at creation time. The menu item for this action item is given the specified title
, and placed before the menu item specified by beforeId
.
<Interface>CreateSeparator <guid>id beforeId:<guid>
CreateSeparator - no automatic redraw after invoked
beforeId default value: "00000000-0000-0000-0000-000000000000"
Creates a menu separator and places it before the menu item specified by beforeId
.
<boolean>DeleteItem <guid>id
DeleteItem - no automatic redraw after invoked
Deletes the menu item with the specified id
.
<void>Popup <point2>pos applyUIScaling:<boolean>
Popup - no automatic redraw after invoked
applyUIScaling default value: true
Pops up (displays) the dynamic menu at the specified pos
, optionally applying UI scaling if applyUIScaling
is true.
<Interface>AddSubMenu <string>title
AddSubMenu - no automatic redraw after invoked
Adds a sub-menu with the specified title
to the dynamic menu.
<Interface>AddAction <integer>tableId <string>persistentActionId title:<string>
AddAction - no automatic redraw after invoked
title default value: undefined
Adds a CuiActionItem with the specified tableId
, persistentActionId
and title
to the dynamic menu.
<Interface>AddMacroScriptAction <string>macroScriptName <string>macroScriptCategory title:<string>
AddMacroScriptAction - no automatic redraw after invoked
title default value: undefined
Adds a macroScript-based menu item to the dynamic menu specified by macroScriptName
and macroScriptCategory
. If title
is specified, it is used instead of the button text provided by the macroScript action.
<Interface>AddSeparator()
AddSeparator - no automatic redraw after invoked
Adds a menu separator to the dynamic menu.
<Interface>AddItem <integer>itemId <string>title flags:<enum> iconName:<string> toolTip:<string>
AddItem - no automatic redraw after invoked
flags enums: {#disabled|#checked}
flags default value: 0
iconName default value: undefined
toolTip default value: undefined
Adds a menu item with the specified itemId
, title
and flags
to the dynamic menu. This method is used in macroscripts where the itemId is the value passed to the dynamicMenuItemSelected handler.
Optionally a multi-resolution icon can be displayed by specifying iconName
. The path, basename and the extension of the file is used to find matching icons. If you omit the file extension, .png / .svg is assumed. For more information about icon loading and naming conventions, see MaxSDK::LoadMaxMultiResIcon.
An additional tooltip for the menu item can be shown with the toolTip
argument. Note that it is not displayed if it is equal to the title.
<Interface>CreateItem <guid>id <integer>itemId <string>title flags:<enum> beforeId:<guid>
CreateItem - no automatic redraw after invoked
flags enums: {#disabled|#checked}
flags default value: 0
beforeId default value: "00000000-0000-0000-0000-000000000000"
Creates a menu item with the specified id
, itemId
, title
and flags
, and adds it to the dynamic menu in the position before the menu item specified by beforeId.