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

PopupMenu is a 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)

Emitted when user navigated to an item of some id using ui_up or ui_down action.

    "id_pressed" (int id)

Emitted when an item of some id is pressed or its accelerator is activated.

    "index_pressed" (int index)

Emitted when an item of some index is pressed or its accelerator is activated.

Properties

    public bool AllowSearch { get; set; }

If true, allows to navigate PopupMenu with letter keys.

    public bool HideOnCheckableItemSelection { get; set; }

If true, hides the PopupMenu when a checkbox or radio button is selected.

    public bool HideOnItemSelection { get; set; }

If true, hides the PopupMenu when an item is selected.

    public bool HideOnStateItemSelection { get; set; }

If true, hides the PopupMenu when a state item is selected.

    public Collections.Array Items { get; set; }

    public float SubmenuPopupDelay { get; set; }

Sets the delay time in seconds 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.

Methods

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

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

Adds a new checkable item and assigns the specified ShortCut to it. Sets the label of the checkbox to the ShortCut’s name.

An id can optionally be provided. If no id is provided, one will be created from the index.

Note: Checkable items just display a checkmark, but don’t have any built-in checking behavior and must be checked/unchecked manually. See SetItemChecked(int, bool) for more info on how to control it.

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

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

Adds a new checkable item and assigns the specified ShortCut and icon texture to it. Sets the label of the checkbox to the ShortCut’s name.

An id can optionally be provided. If no id is provided, one will be created from the index.

Note: Checkable items just display a checkmark, but don’t have any built-in checking behavior and must be checked/unchecked manually. See SetItemChecked(int, bool) for more info on how to control it.

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

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

Adds a new item and assigns the specified ShortCut and icon texture to it. Sets the label of the checkbox to the ShortCut’s name.

An id can optionally be provided. If no id is provided, one will be created from the index.

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

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

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

Adds a new radio check button and assigns a ShortCut to it. Sets the label of the checkbox to the ShortCut’s name.

An id can optionally be provided. If no id is provided, one will be created from the index.

Note: Checkable items just display a checkmark, but don’t have any built-in checking behavior and must be checked/unchecked manually. See SetItemChecked(int, bool) for more info on how to control it.

    public void AddSeparator(string label = "")

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

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

Adds a ShortCut.

An id can optionally be provided. If no id is provided, one will be created from the index.

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

Adds an item that will act as a submenu of the parent PopupMenu node when clicked. The submenu argument is the name of the child PopupMenu node that will be shown when the item is clicked.

An id can optionally be provided. If no id is provided, one will be created from the index.

    public void Clear()

Removes all items from the PopupMenu.

    [Obsolete("GetAllowSearch is deprecated. Use the AllowSearch property instead.")]
    public bool GetAllowSearch()

Getter for AllowSearch

    public uint GetItemAccelerator(int idx)

    public int GetItemCount()

Returns the number of items in the PopupMenu.

    public Texture GetItemIcon(int idx)

Returns the icon of the item at index idx.

    public int GetItemId(int idx)

Returns the id of the item at index idx. id can be manually assigned, while index can not.

    public int GetItemIndex(int id)

Returns the index of the item containing the specified id. Index is automatically assigned to each item by the engine. Index can not be set manually.

    public object GetItemMetadata(int idx)

Returns the metadata of the specified 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)

Returns the ShortCut associated with the specified idx item.

    public string GetItemSubmenu(int idx)

Returns the submenu name of the item at index idx. See AddSubmenuItem(string, string, int) for more info on how to add a submenu.

    public string GetItemText(int idx)

Returns the text of the item at index idx.

    public string GetItemTooltip(int idx)

Returns the tooltip associated with the specified index index idx.

    [Obsolete("GetSubmenuPopupDelay is deprecated. Use the SubmenuPopupDelay property instead.")]
    public float GetSubmenuPopupDelay()

Getter for SubmenuPopupDelay

    [Obsolete("IsHideOnCheckableItemSelection is deprecated. Use the HideOnCheckableItemSelection property instead.")]
    public bool IsHideOnCheckableItemSelection()

Getter for HideOnCheckableItemSelection

    [Obsolete("IsHideOnItemSelection is deprecated. Use the HideOnItemSelection property instead.")]
    public bool IsHideOnItemSelection()

Getter for HideOnItemSelection

    [Obsolete("IsHideOnStateItemSelection is deprecated. Use the HideOnStateItemSelection property instead.")]
    public bool IsHideOnStateItemSelection()

Getter for HideOnStateItemSelection

    public bool IsHideOnWindowLoseFocus()

Returns whether the popup will be hidden when the window loses focus or not.

    public bool IsItemCheckable(int idx)

Returns true if the item at index idx is checkable in some way, i.e. if it has a checkbox or radio button.

Note: 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)

Returns true if the item at index idx is checked.

    public bool IsItemDisabled(int idx)

Returns true if the item at index idx is disabled. When it is disabled it can’t be selected, or its action invoked.

See SetItemDisabled(int, bool) for more info on how to disable an item.

    public bool IsItemRadioCheckable(int idx)

Returns true if the item at index idx has radio button-style checkability.

Note: This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.

    public bool IsItemSeparator(int idx)

Returns true if the item is a separator. If it is, it will be displayed as a line. See AddSeparator(string) for more info on how to add a separator.

    public bool IsItemShortcutDisabled(int idx)

Returns whether the shortcut of the specified item idx is disabled or not.

    public void RemoveItem(int idx)

Removes the item at index idx from the menu.

Note: The indices of items after the removed item will be shifted by one.

    [Obsolete("SetAllowSearch is deprecated. Use the AllowSearch property instead.")]
    public void SetAllowSearch(bool allow)

Setter for AllowSearch

    [Obsolete("SetHideOnCheckableItemSelection is deprecated. Use the HideOnCheckableItemSelection property instead.")]
    public void SetHideOnCheckableItemSelection(bool enable)

Setter for HideOnCheckableItemSelection

    [Obsolete("SetHideOnItemSelection is deprecated. Use the HideOnItemSelection property instead.")]
    public void SetHideOnItemSelection(bool enable)

Setter for HideOnItemSelection

    [Obsolete("SetHideOnStateItemSelection is deprecated. Use the HideOnStateItemSelection property instead.")]
    public void SetHideOnStateItemSelection(bool enable)

Setter for HideOnStateItemSelection

    public void SetHideOnWindowLoseFocus(bool enable)

Hides the PopupMenu when the window loses focus.

    public void SetItemAccelerator(int idx, uint accel)

    public void SetItemAsCheckable(int idx, bool enable)

Sets whether the item at index idx has a checkbox. If false, sets the type of the item to plain text.

Note: 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)

Sets the type of the item at the specified index idx to radio button. If false, sets the type of the item to plain text.

    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. If false, sets the type of the item to plain text.

    public void SetItemChecked(int idx, bool @checked)

Sets 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 and its action can’t be invoked.

    public void SetItemIcon(int idx, Texture icon)

Replaces the Texture icon of the specified idx.

    public void SetItemId(int idx, int id)

Sets the id of the item at index idx.

    public void SetItemMetadata(int idx, object metadata)

Sets the metadata of an item, which may 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)

Sets a ShortCut for the specified item idx.

    public void SetItemShortcutDisabled(int idx, bool disabled)

Disables the ShortCut of the specified index idx.

    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)

Sets the text of the item at index idx.

    public void SetItemTooltip(int idx, string tooltip)

Sets the String tooltip of the item at the specified index idx.

    [Obsolete("SetSubmenuPopupDelay is deprecated. Use the SubmenuPopupDelay property instead.")]
    public void SetSubmenuPopupDelay(float seconds)

Setter for SubmenuPopupDelay

    public void ToggleItemChecked(int idx)

Toggles the check state of the item of the specified index idx.

    public void ToggleItemMultistate(int idx)
Tags: