Button control that provides selectable options when pressed.
    public class OptionButton : Button

OptionButton is a type button that provides a selectable list of items when pressed. The item selected becomes the “current” item and is displayed as the button text.

Inheritance Chain

Constructors

    public OptionButton()

Signals

    "item_focused" (int id)

Emitted the when user navigates to an item using the ui_up or ui_down actions. The index of the item selected is passed as argument.

    "item_selected" (int id)

Emitted when the current item has been changed by the user. The index of the item selected is passed as argument.

Properties

    public Collections.Array Items { get; set; }

    public int Selected { get; set; }

Methods

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

Adds an item, with a texture icon, text label and (optionally) id. If no id is passed, id becomes the item index. New items are appended at the end.

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

Adds an item, with text label and (optionally) id. If no id is passed, id becomes the item index. New items are appended at the end.

    public void AddSeparator()

Adds a separator to the list of items. Separators help to group items. Separator also takes up an index and is appended at the end.

    public void Clear()

Clear all the items in the OptionButton.

    public int GetItemCount()

Returns the amount of items in the OptionButton.

    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.

    public int GetItemIndex(int id)

Returns the index of the item with the given id.

    public object GetItemMetadata(int idx)

    public string GetItemText(int idx)

Returns the text of the item at index idx.

    public PopupMenu GetPopup()

Returns the PopupMenu contained in this button.

    [Obsolete("GetSelected is deprecated. Use the Selected property instead.")]
    public int GetSelected()

Getter for Selected

    public int GetSelectedId()

    public object GetSelectedMetadata()

    public bool IsItemDisabled(int idx)

    public void RemoveItem(int idx)

    public void Select(int idx)

Select an item by index and make it the current item.

    public void SetItemDisabled(int idx, bool disabled)

    public void SetItemIcon(int idx, Texture texture)

Sets the icon of an item at index idx.

    public void SetItemId(int idx, int id)

Sets the ID of an item at index idx.

    public void SetItemMetadata(int idx, object metadata)

    public void SetItemText(int idx, string text)

Sets the text of an item at index idx.

Tags: