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_selected" (int ID)

This signal is emitted when the current item was changed by the user. ID of the item selected is passed as argument (if no IDs were added, ID will be just the item index).

Properties

    public object[] Items { get; set; }

    public int Selected { get; set; }

Methods

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

Add 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)

Add 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()

Add 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()

Return the amount of items in the OptionButton.

    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 object GetItemMetadata(int idx)

    public string GetItemText(int idx)

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

    public PopupMenu GetPopup()

Return the PopupMenu contained in this button.

    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)

Set the icon of an item at index “idx”.

    public void SetItemId(int idx, int id)

Set the ID of an item at index “idx”.

    public void SetItemMetadata(int idx, object metadata)

    public void SetItemText(int idx, string text)

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

Tags: