PopupMenu displays a list of options.
    public class PopupMenu : Popup

PopupMenu is the typical Control that displays a list of options. They are popular in toolbars or context menus.

Inheritance Chain

Constructors

    public PopupMenu()

Signals

    "id_focused" (int ID)

This event is emitted when user navigated to an item of some id using ui_up or ui_down action.

    "id_pressed" (int ID)

This event is emitted when an item of some id is pressed or its accelerator is activated.

    "index_pressed" (int index)

This event is emitted when an item of some index is pressed or its accelerator is activated.

Properties

    public bool HideOnCheckableItemSelection { get; set; }

    public bool HideOnItemSelection { get; set; }

    public bool HideOnStateItemSelection { get; set; }

    public Collections.Array Items { get; set; }

    public float SubmenuPopupDelay { get; set; }

Sets the delay time for the submenu item to popup on mouse hovering. If the popup menu is added as a child of another (acting as a submenu), it will inherit the delay time of the parent menu item. Default value: 0.3 seconds.

Methods

    public void AddCheckItem(string label, int id = -1, int accel = 0)

Add a new checkable item with text “label”. An id can optionally be provided, as well as an accelerator. If no id is provided, one will be created from the index. Note that checkable items just display a checkmark, but don’t have any built-in checking behavior and must be checked/unchecked manually.

    public void AddCheckShortcut(ShortCut shortcut, int id = -1, bool global = false)

    public void AddIconCheckItem(Texture texture, string label, int id = -1, int accel = 0)

Add a new checkable item with text “label” and icon “texture”. An id can optionally be provided, as well as an accelerator. If no id is provided, one will be

created from the index. Note that checkable items just display a checkmark, but don’t have any built-in checking behavior and must be checked/unchecked manually.

    public void AddIconCheckShortcut(Texture texture, ShortCut shortcut, int id = -1, bool global = false)

    public void AddIconItem(Texture texture, string label, int id = -1, int accel = 0)

Add a new item with text “label” and icon “texture”. An id can optionally be provided, as well as an accelerator keybinding. If no id is provided, one will be created from the index.

    public void AddIconShortcut(Texture texture, ShortCut shortcut, int id = -1, bool global = false)

    public void AddItem(string label, int id = -1, int accel = 0)

Add a new item with text “label”. An id can optionally be provided, as well as an accelerator keybinding. If no id is provided, one will be created from the index.

    public void AddRadioCheckItem(string label, int id = -1, int accel = 0)

The same as AddCheckItem(string, int, int) but the inserted item will look as a radio button. Remember this is just cosmetic and you have to add the logic for checking/unchecking items in radio groups.

    public void AddRadioCheckShortcut(ShortCut shortcut, int id = -1, bool global = false)

    public void AddSeparator(string label = "")

Add a separator between items. Separators also occupy an index.

    public void AddShortcut(ShortCut shortcut, int id = -1, bool global = false)

    public void AddSubmenuItem(string label, string submenu, int id = -1)

Adds an item with a submenu. The submenu is the name of a child PopupMenu node that would be shown when the item is clicked. An id can optionally be provided, but if is isn’t provided, one will be created from the index.

    public void Clear()

Clear the popup menu, in effect removing all items.

    public int GetItemAccelerator(int idx)

Return the accelerator of the item at index “idx”. Accelerators are special combinations of keys that activate the item, no matter which control is focused.

    public int GetItemCount()

Return the amount of items.

    public Texture GetItemIcon(int idx)

Return the icon of the item at index “idx”.

    public int GetItemId(int idx)

Return the id of the item at index “idx”.

    public int GetItemIndex(int id)

Find and return the index of the item containing a given id.

    public object GetItemMetadata(int idx)

Return the metadata of an item, which might be of any type. You can set it with SetItemMetadata(int, object), which provides a simple way of assigning context data to items.

    public ShortCut GetItemShortcut(int idx)

    public string GetItemSubmenu(int idx)

Return the submenu name of the item at index “idx”.

    public string GetItemText(int idx)

Return the text of the item at index “idx”.

    public string GetItemTooltip(int idx)

    public float GetSubmenuPopupDelay()

Getter for SubmenuPopupDelay

    public bool IsHideOnCheckableItemSelection()

Getter for HideOnCheckableItemSelection

    public bool IsHideOnItemSelection()

Getter for HideOnItemSelection

    public bool IsHideOnStateItemSelection()

Getter for HideOnStateItemSelection

    public bool IsHideOnWindowLoseFocus()

    public bool IsItemCheckable(int idx)

Return whether the item at index “idx” is checkable in some way, i.e., whether has a checkbox or radio button. Note that checkable items just display a checkmark or radio button, but don’t have any built-in checking behavior and must be checked/unchecked manually.

    public bool IsItemChecked(int idx)

Return whether the item at index “idx” is checked.

    public bool IsItemDisabled(int idx)

Return whether the item at index “idx” is disabled. When it is disabled it can’t be selected, or its action invoked.

    public bool IsItemRadioCheckable(int idx)

Return whether the item at index “idx” has radio-button-style checkability. Remember this is just cosmetic and you have to add the logic for checking/unchecking items in radio groups.

    public bool IsItemSeparator(int idx)

Return whether the item is a separator. If it is, it would be displayed as a line.

    public bool IsItemShortcutDisabled(int idx)

    public void RemoveItem(int idx)

Removes the item at index “idx” from the menu. Note that the indexes of items after the removed item are going to be shifted by one.

    public void SetHideOnCheckableItemSelection(bool enable)

Setter for HideOnCheckableItemSelection

    public void SetHideOnItemSelection(bool enable)

Setter for HideOnItemSelection

    public void SetHideOnStateItemSelection(bool enable)

Setter for HideOnStateItemSelection

    public void SetHideOnWindowLoseFocus(bool enable)

    public void SetItemAccelerator(int idx, int accel)

Set the accelerator of the item at index “idx”. Accelerators are special combinations of keys that activate the item, no matter which control is focused.

    public void SetItemAsCheckable(int idx, bool enable)

Set whether the item at index “idx” has a checkbox. Note that checkable items just display a checkmark, but don’t have any built-in checking behavior and must be checked/unchecked manually.

    public void SetItemAsRadioCheckable(int idx, bool enable)

The same as SetItemAsCheckable(int, bool) but placing a radio button in case of enabling. If used for disabling, it’s the same.

Remember this is just cosmetic and you have to add the logic for checking/unchecking items in radio groups.

    public void SetItemAsSeparator(int idx, bool enable)

Mark the item at index “idx” as a separator, which means that it would be displayed as a line.

    public void SetItemChecked(int idx, bool @checked)

Set the checkstate status of the item at index “idx”.

    public void SetItemDisabled(int idx, bool disabled)

Sets whether the item at index “idx” is disabled or not. When it is disabled it can’t be selected, or its action invoked.

    public void SetItemIcon(int idx, Texture icon)

    public void SetItemId(int idx, int id)

Set the id of the item at index “idx”.

    public void SetItemMetadata(int idx, object metadata)

Sets the metadata of an item, which might be of any type. You can later get it with GetItemMetadata(int), which provides a simple way of assigning context data to items.

    public void SetItemMultistate(int idx, int state)

    public void SetItemShortcut(int idx, ShortCut shortcut, bool global = false)

    public void SetItemShortcutDisabled(int idx, bool disabled)

    public void SetItemSubmenu(int idx, string submenu)

Sets the submenu of the item at index “idx”. The submenu is the name of a child PopupMenu node that would be shown when the item is clicked.

    public void SetItemText(int idx, string text)

Set the text of the item at index “idx”.

    public void SetItemTooltip(int idx, string tooltip)

    public void SetSubmenuPopupDelay(float seconds)

Setter for SubmenuPopupDelay

    public void ToggleItemChecked(int idx)

    public void ToggleItemMultistate(int idx)
Tags: