Blockbench Reference Docs
    Preparing search index...

    Use the Menu class to create a context menu. Menus can contain custom entries and hierarchy, or existing actions and tools.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Methods

    • Adds an action to the menu structure

      Parameters

      • action: Action | CustomMenuItem | "_"

        Action to add

      • Optionalpath: string | number

        Path pointing to the location. Use the ID of each level of the menu, or index within a level, separated by a point. For example, export.0 places the action at the top position of the Export submenu.

      Returns void

    • Returns boolean

    • Returns void

    • Parameters

      Returns void

      Use removeAction instead

    • Closes the menu if it's open

      Returns this

    • Parameters

      • node: HTMLElement
      • Optionalevent: Event
      • Optionalexpand: boolean

      Returns void

    • Returns void

    • Opens the menu somewhere

      Parameters

      • Optionalposition: MenuOpenPositionAnchor

        Position where to open the menu. Can be a mouse event, or a node that the menu is spawned below.

      • Optionalcontext: any

        Context for the click events inside the menu

      Returns this

    • Remove an action or menu item from the menu

      Parameters

      • path: string | Action

        Path pointing to the location. Use the ID of each level of the menu, or index within a level, or item ID, separated by a point. For example, export.export_special_format removes the action "Export Special Format" from the Export submenu.

      Returns void

    Properties

    children: []
    highlight_action?: MenuItem
    id: string
    node: HTMLUListElement
    options?: MenuOptions
    structure: MenuItem[] | ((context: any) => MenuItem[])
    type: string
    closed_in_this_click?: string
    open: Menu