123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- :github_url: hide
- .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
- .. DO NOT EDIT THIS FILE, but the OptionButton.xml source instead.
- .. The source is found in doc/classes or modules/<name>/doc_classes.
- .. _class_OptionButton:
- OptionButton
- ============
- **Inherits:** :ref:`Button<class_Button>` **<** :ref:`BaseButton<class_BaseButton>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
- **Category:** Core
- Brief Description
- -----------------
- Button control that provides selectable options when pressed.
- Properties
- ----------
- +-----------------------+-------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`selected<class_OptionButton_property_selected>` |
- +-----------------------+-------------------------------------------------------+
- Methods
- -------
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`add_icon_item<class_OptionButton_method_add_icon_item>` **(** :ref:`Texture<class_Texture>` texture, :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1 **)** |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`add_item<class_OptionButton_method_add_item>` **(** :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1 **)** |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`add_separator<class_OptionButton_method_add_separator>` **(** **)** |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`clear<class_OptionButton_method_clear>` **(** **)** |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_item_count<class_OptionButton_method_get_item_count>` **(** **)** const |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Texture<class_Texture>` | :ref:`get_item_icon<class_OptionButton_method_get_item_icon>` **(** :ref:`int<class_int>` idx **)** const |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_item_id<class_OptionButton_method_get_item_id>` **(** :ref:`int<class_int>` idx **)** const |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_item_index<class_OptionButton_method_get_item_index>` **(** :ref:`int<class_int>` id **)** const |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Variant<class_Variant>` | :ref:`get_item_metadata<class_OptionButton_method_get_item_metadata>` **(** :ref:`int<class_int>` idx **)** const |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_item_text<class_OptionButton_method_get_item_text>` **(** :ref:`int<class_int>` idx **)** const |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PopupMenu<class_PopupMenu>` | :ref:`get_popup<class_OptionButton_method_get_popup>` **(** **)** const |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_selected_id<class_OptionButton_method_get_selected_id>` **(** **)** const |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Variant<class_Variant>` | :ref:`get_selected_metadata<class_OptionButton_method_get_selected_metadata>` **(** **)** const |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_item_disabled<class_OptionButton_method_is_item_disabled>` **(** :ref:`int<class_int>` idx **)** const |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`remove_item<class_OptionButton_method_remove_item>` **(** :ref:`int<class_int>` idx **)** |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`select<class_OptionButton_method_select>` **(** :ref:`int<class_int>` idx **)** |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_item_disabled<class_OptionButton_method_set_item_disabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)** |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_item_icon<class_OptionButton_method_set_item_icon>` **(** :ref:`int<class_int>` idx, :ref:`Texture<class_Texture>` texture **)** |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_item_id<class_OptionButton_method_set_item_id>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)** |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_item_metadata<class_OptionButton_method_set_item_metadata>` **(** :ref:`int<class_int>` idx, :ref:`Variant<class_Variant>` metadata **)** |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_item_text<class_OptionButton_method_set_item_text>` **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` text **)** |
- +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- Theme Properties
- ----------------
- +---------------------------------+---------------------+
- | :ref:`Texture<class_Texture>` | arrow |
- +---------------------------------+---------------------+
- | :ref:`int<class_int>` | arrow_margin |
- +---------------------------------+---------------------+
- | :ref:`StyleBox<class_StyleBox>` | disabled |
- +---------------------------------+---------------------+
- | :ref:`StyleBox<class_StyleBox>` | focus |
- +---------------------------------+---------------------+
- | :ref:`Font<class_Font>` | font |
- +---------------------------------+---------------------+
- | :ref:`Color<class_Color>` | font_color |
- +---------------------------------+---------------------+
- | :ref:`Color<class_Color>` | font_color_disabled |
- +---------------------------------+---------------------+
- | :ref:`Color<class_Color>` | font_color_hover |
- +---------------------------------+---------------------+
- | :ref:`Color<class_Color>` | font_color_pressed |
- +---------------------------------+---------------------+
- | :ref:`StyleBox<class_StyleBox>` | hover |
- +---------------------------------+---------------------+
- | :ref:`int<class_int>` | hseparation |
- +---------------------------------+---------------------+
- | :ref:`StyleBox<class_StyleBox>` | normal |
- +---------------------------------+---------------------+
- | :ref:`StyleBox<class_StyleBox>` | pressed |
- +---------------------------------+---------------------+
- Signals
- -------
- .. _class_OptionButton_signal_item_focused:
- - **item_focused** **(** :ref:`int<class_int>` ID **)**
- This signal is emitted when user navigated to an item using ``ui_up`` or ``ui_down`` action. ID of the item selected is passed as argument.
- ----
- .. _class_OptionButton_signal_item_selected:
- - **item_selected** **(** :ref:`int<class_int>` ID **)**
- This signal is emitted when the current item was changed by the user. Index of the item selected is passed as argument.
- 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.
- Property Descriptions
- ---------------------
- .. _class_OptionButton_property_selected:
- - :ref:`int<class_int>` **selected**
- +----------+----------------+
- | *Getter* | get_selected() |
- +----------+----------------+
- Method Descriptions
- -------------------
- .. _class_OptionButton_method_add_icon_item:
- - void **add_icon_item** **(** :ref:`Texture<class_Texture>` texture, :ref:`String<class_String>` label, :ref:`int<class_int>` id=-1 **)**
- 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_method_add_item:
- - void **add_item** **(** :ref:`String<class_String>` label, :ref:`int<class_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.
- ----
- .. _class_OptionButton_method_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_method_clear:
- - void **clear** **(** **)**
- Clear all the items in the ``OptionButton``.
- ----
- .. _class_OptionButton_method_get_item_count:
- - :ref:`int<class_int>` **get_item_count** **(** **)** const
- Returns the amount of items in the OptionButton.
- ----
- .. _class_OptionButton_method_get_item_icon:
- - :ref:`Texture<class_Texture>` **get_item_icon** **(** :ref:`int<class_int>` idx **)** const
- Returns the icon of the item at index "idx".
- ----
- .. _class_OptionButton_method_get_item_id:
- - :ref:`int<class_int>` **get_item_id** **(** :ref:`int<class_int>` idx **)** const
- Returns the ID of the item at index ``idx``.
- ----
- .. _class_OptionButton_method_get_item_index:
- - :ref:`int<class_int>` **get_item_index** **(** :ref:`int<class_int>` id **)** const
- Returns the index of the item with the given ``id``.
- ----
- .. _class_OptionButton_method_get_item_metadata:
- - :ref:`Variant<class_Variant>` **get_item_metadata** **(** :ref:`int<class_int>` idx **)** const
- ----
- .. _class_OptionButton_method_get_item_text:
- - :ref:`String<class_String>` **get_item_text** **(** :ref:`int<class_int>` idx **)** const
- Returns the text of the item at index "idx".
- ----
- .. _class_OptionButton_method_get_popup:
- - :ref:`PopupMenu<class_PopupMenu>` **get_popup** **(** **)** const
- Returns the :ref:`PopupMenu<class_PopupMenu>` contained in this button.
- ----
- .. _class_OptionButton_method_get_selected_id:
- - :ref:`int<class_int>` **get_selected_id** **(** **)** const
- ----
- .. _class_OptionButton_method_get_selected_metadata:
- - :ref:`Variant<class_Variant>` **get_selected_metadata** **(** **)** const
- ----
- .. _class_OptionButton_method_is_item_disabled:
- - :ref:`bool<class_bool>` **is_item_disabled** **(** :ref:`int<class_int>` idx **)** const
- ----
- .. _class_OptionButton_method_remove_item:
- - void **remove_item** **(** :ref:`int<class_int>` idx **)**
- ----
- .. _class_OptionButton_method_select:
- - void **select** **(** :ref:`int<class_int>` idx **)**
- Select an item by index and make it the current item.
- ----
- .. _class_OptionButton_method_set_item_disabled:
- - void **set_item_disabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` disabled **)**
- ----
- .. _class_OptionButton_method_set_item_icon:
- - void **set_item_icon** **(** :ref:`int<class_int>` idx, :ref:`Texture<class_Texture>` texture **)**
- Set the icon of an item at index "idx".
- ----
- .. _class_OptionButton_method_set_item_id:
- - void **set_item_id** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` id **)**
- Set the ID of an item at index "idx".
- ----
- .. _class_OptionButton_method_set_item_metadata:
- - void **set_item_metadata** **(** :ref:`int<class_int>` idx, :ref:`Variant<class_Variant>` metadata **)**
- ----
- .. _class_OptionButton_method_set_item_text:
- - void **set_item_text** **(** :ref:`int<class_int>` idx, :ref:`String<class_String>` text **)**
- Set the text of an item at index "idx".
|