Share

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"
        menuRoot.AddItem 2345 "Say Goodbye in 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>AddSeparator()
       AddSeparator - no automatic redraw after invoked

Adds a menu separator to the dynamic menu.

    <Interface>AddItem <integer>itemId <string>title flags:<enum>
       AddItem - no automatic redraw after invoked
       flags enums: {#disabled|#checked}
       flags default value: 0

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.

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

Was this information helpful?