Class CCMenu

Holds information about a single menu in the menu bar, either as a top-level menu or a submenu.

Constructors

Properties

supermenu?: CCMenu

The menu that contains this menu.

Accessors

  • get length(): number
  • The number of items in the menu.

    Returns number

Methods

  • Adds an item to the end of the menu.

    Parameters

    Returns void

  • Constructs and adds a new item with an action.

    Parameters

    • title: string

      The title of the item

    • action: () => void

      The function to call when the item is clicked

    • OptionalkeyEquivalent: CCKeyCombo

      A key combo to trigger the action with

    Returns void

  • Returns the index of the specified menu item.

    Parameters

    Returns undefined | number

    The item's index, or undefined if not found

  • Returns the index of the first menu item with the specified submenu.

    Parameters

    • menu: CCMenu

      The menu to look for

    Returns undefined | number

    The found item's index, or undefined if not found

  • Returns the index of the first menu item with the specified title.

    Parameters

    • title: string

      The title to look for

    Returns undefined | number

    The found item's index, or undefined if not found

  • Inserts an item at the specified index.

    Parameters

    • item: CCMenuItem

      The item to add

    • index: number

      The index to add at

    Returns void

  • Returns the menu item at the specified index.

    Parameters

    • index: number

      The index of the item

    Returns undefined | CCMenuItem

    The found item, or undefined if not found

  • Returns the first menu item with the specified title.

    Parameters

    • title: string

      The title to look for

    Returns undefined | CCMenuItem

    The found item, or undefined if not found

  • Removes an item at the specified index from the menu.

    Parameters

    • index: number

      The index of the item to remove

    Returns void

  • Triggers an incoming action on a nested subitem.

    Parameters

    • key: string

      The key of the item that was triggered

    Returns boolean

    Whether an item triggered an action