.. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead. .. _class_OptionButton: OptionButton ============ **Inherits:** :ref:`Button` **<** :ref:`BaseButton` **<** :ref:`Control` **<** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` **Category:** Core Brief Description ----------------- Button control that provides selectable options when pressed. Member Functions ---------------- +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_icon_item` **(** :ref:`Texture` texture, :ref:`String` label, :ref:`int` id **)** | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_item` **(** :ref:`String` label, :ref:`int` id=null **)** | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_separator` **(** **)** | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear` **(** **)** | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_item_count` **(** **)** const | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Texture` | :ref:`get_item_icon` **(** :ref:`int` idx **)** const | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_item_id` **(** :ref:`int` idx **)** const | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Variant` | :ref:`get_item_metadata` **(** :ref:`int` idx **)** const | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_item_text` **(** :ref:`int` idx **)** const | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_selected` **(** **)** const | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_selected_id` **(** **)** const | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Variant` | :ref:`get_selected_metadata` **(** **)** const | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_item_disabled` **(** :ref:`int` idx **)** const | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove_item` **(** :ref:`int` idx **)** | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`select` **(** :ref:`int` idx **)** | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_item_disabled` **(** :ref:`int` idx, :ref:`bool` disabled **)** | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_item_icon` **(** :ref:`int` idx, :ref:`Texture` texture **)** | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_item_id` **(** :ref:`int` idx, :ref:`int` id **)** | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_item_metadata` **(** :ref:`int` idx, :ref:`Variant` metadata **)** | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_item_text` **(** :ref:`int` idx, :ref:`String` text **)** | +--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Signals ------- - **item_selected** **(** :ref:`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). Description ----------- 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. Member Function Description --------------------------- .. _class_OptionButton_add_icon_item: - void **add_icon_item** **(** :ref:`Texture` texture, :ref:`String` label, :ref:`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. .. _class_OptionButton_add_item: - void **add_item** **(** :ref:`String` label, :ref:`int` id=null **)** 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. .. _class_OptionButton_add_separator: - void **add_separator** **(** **)** 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. .. _class_OptionButton_clear: - void **clear** **(** **)** Clear all the items in the :ref:`OptionButton`. .. _class_OptionButton_get_item_count: - :ref:`int` **get_item_count** **(** **)** const Return the amount of items in the OptionButton. .. _class_OptionButton_get_item_icon: - :ref:`Texture` **get_item_icon** **(** :ref:`int` idx **)** const Return the icon of the item at index "idx". .. _class_OptionButton_get_item_id: - :ref:`int` **get_item_id** **(** :ref:`int` idx **)** const Return the ID of the item at index "idx". .. _class_OptionButton_get_item_metadata: - :ref:`Variant` **get_item_metadata** **(** :ref:`int` idx **)** const .. _class_OptionButton_get_item_text: - :ref:`String` **get_item_text** **(** :ref:`int` idx **)** const Return the text of the item at index "idx". .. _class_OptionButton_get_selected: - :ref:`int` **get_selected** **(** **)** const Return the current item index .. _class_OptionButton_get_selected_id: - :ref:`int` **get_selected_id** **(** **)** const .. _class_OptionButton_get_selected_metadata: - :ref:`Variant` **get_selected_metadata** **(** **)** const .. _class_OptionButton_is_item_disabled: - :ref:`bool` **is_item_disabled** **(** :ref:`int` idx **)** const .. _class_OptionButton_remove_item: - void **remove_item** **(** :ref:`int` idx **)** .. _class_OptionButton_select: - void **select** **(** :ref:`int` idx **)** Select an item by index and make it the current item. .. _class_OptionButton_set_item_disabled: - void **set_item_disabled** **(** :ref:`int` idx, :ref:`bool` disabled **)** .. _class_OptionButton_set_item_icon: - void **set_item_icon** **(** :ref:`int` idx, :ref:`Texture` texture **)** Set the icon of an item at index "idx". .. _class_OptionButton_set_item_id: - void **set_item_id** **(** :ref:`int` idx, :ref:`int` id **)** Set the ID of an item at index "idx". .. _class_OptionButton_set_item_metadata: - void **set_item_metadata** **(** :ref:`int` idx, :ref:`Variant` metadata **)** .. _class_OptionButton_set_item_text: - void **set_item_text** **(** :ref:`int` idx, :ref:`String` text **)** Set the text of an item at index "idx".