Struct OptionButton

Button control that provides selectable options when pressed.

struct OptionButton ;

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.

Properties

NameTypeDescription
items[get, set] Array
selected[get, set] longThe index of the currently selected item, or -1 if no item is selected.

Methods

NameDescription
_focused
_getItems
_selected
_selectInt
_setItems
addIconItem Adds an item, with a texture icon, text label and (optionally) id. If no id is passed, the item index will be used as the item's ID. New items are appended at the end.
addItem Adds an item, with text label and (optionally) id. If no id is passed, the item index will be used as the item's ID. New items are appended at the end.
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.
clear Clears all the items in the OptionButton.
getItemCount Returns the amount of items in the OptionButton, including separators.
getItemIcon Returns the icon of the item at index idx.
getItemId Returns the ID of the item at index idx.
getItemIndex Returns the index of the item with the given id.
getItemMetadata Retrieves the metadata of an item. Metadata may be any type and can be used to store extra information about an item, such as an external string ID.
getItemText Returns the text of the item at index idx.
getPopup Returns the PopupMenu contained in this button.
getSelected
getSelectedId Returns the ID of the selected item, or 0 if no item is selected.
getSelectedMetadata Gets the metadata of the selected item. Metadata for items can be set using setItemMetadata.
isItemDisabled Returns true if the item at index idx is disabled.
removeItem Removes the item at index idx.
select Selects an item by index and makes it the current item. This will work even if the item is disabled.
setItemDisabled Sets whether the item at index idx is disabled. Disabled items are drawn differently in the dropdown and are not selectable by the user. If the current selected item is set as disabled, it will remain selected.
setItemIcon Sets the icon of the item at index idx.
setItemId Sets the ID of the item at index idx.
setItemMetadata Sets the metadata of an item. Metadata may be of any type and can be used to store extra information about an item, such as an external string ID.
setItemText Sets the text of the item at index idx.