2017-09-13 04:42:36 +08:00
<?xml version="1.0" encoding="UTF-8" ?>
2020-02-01 09:03:48 +08:00
<class name= "OptionButton" inherits= "Button" version= "4.0" >
2017-09-13 04:42:36 +08:00
<brief_description >
Button control that provides selectable options when pressed.
</brief_description>
<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.
2020-09-24 05:34:28 +08:00
See also [BaseButton] which contains common properties and methods associated with this node.
2017-09-13 04:42:36 +08:00
</description>
<tutorials >
</tutorials>
<methods >
<method name= "add_icon_item" >
<return type= "void" >
</return>
2020-02-12 16:59:06 +08:00
<argument index= "0" name= "texture" type= "Texture2D" >
2017-09-13 04:42:36 +08:00
</argument>
<argument index= "1" name= "label" type= "String" >
</argument>
2018-05-12 15:38:00 +08:00
<argument index= "2" name= "id" type= "int" default= "-1" >
2017-09-13 04:42:36 +08:00
</argument>
<description >
2019-12-18 06:24:54 +08:00
Adds an item, with a [code]texture[/code] icon, text [code]label[/code] and (optionally) [code]id[/code]. If no [code]id[/code] is passed, the item index will be used as the item's ID. New items are appended at the end.
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "add_item" >
<return type= "void" >
</return>
<argument index= "0" name= "label" type= "String" >
</argument>
<argument index= "1" name= "id" type= "int" default= "-1" >
</argument>
<description >
2019-12-18 06:24:54 +08:00
Adds an item, with text [code]label[/code] and (optionally) [code]id[/code]. If no [code]id[/code] is passed, the item index will be used as the item's ID. New items are appended at the end.
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "add_separator" >
<return type= "void" >
</return>
<description >
2019-06-22 07:04:47 +08:00
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.
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "clear" >
<return type= "void" >
</return>
<description >
2019-12-18 06:24:54 +08:00
Clears all the items in the [OptionButton].
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "get_item_count" qualifiers= "const" >
<return type= "int" >
</return>
<description >
2019-12-18 06:24:54 +08:00
Returns the amount of items in the OptionButton, including separators.
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "get_item_icon" qualifiers= "const" >
2020-02-12 16:59:06 +08:00
<return type= "Texture2D" >
2017-09-13 04:42:36 +08:00
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
<description >
2019-06-22 07:04:47 +08:00
Returns the icon of the item at index [code]idx[/code].
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "get_item_id" qualifiers= "const" >
<return type= "int" >
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
<description >
2019-05-24 10:15:43 +08:00
Returns the ID of the item at index [code]idx[/code].
2019-01-28 23:31:24 +08:00
</description>
</method>
2019-02-16 21:40:52 +08:00
<method name= "get_item_index" qualifiers= "const" >
<return type= "int" >
</return>
<argument index= "0" name= "id" type= "int" >
</argument>
<description >
2019-05-24 10:15:43 +08:00
Returns the index of the item with the given [code]id[/code].
2019-02-16 21:40:52 +08:00
</description>
</method>
2017-09-13 04:42:36 +08:00
<method name= "get_item_metadata" qualifiers= "const" >
<return type= "Variant" >
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
<description >
2019-12-18 06:24:54 +08:00
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.
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "get_item_text" qualifiers= "const" >
<return type= "String" >
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
<description >
2019-06-22 07:04:47 +08:00
Returns the text of the item at index [code]idx[/code].
2017-09-13 04:42:36 +08:00
</description>
</method>
2017-12-25 23:24:10 +08:00
<method name= "get_popup" qualifiers= "const" >
<return type= "PopupMenu" >
</return>
<description >
2019-05-24 10:15:43 +08:00
Returns the [PopupMenu] contained in this button.
2017-12-25 23:24:10 +08:00
</description>
</method>
2017-09-13 04:42:36 +08:00
<method name= "get_selected_id" qualifiers= "const" >
<return type= "int" >
</return>
<description >
2019-12-18 06:24:54 +08:00
Returns the ID of the selected item, or [code]0[/code] if no item is selected.
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "get_selected_metadata" qualifiers= "const" >
<return type= "Variant" >
</return>
<description >
2019-12-18 06:24:54 +08:00
Gets the metadata of the selected item. Metadata for items can be set using [method set_item_metadata].
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "is_item_disabled" qualifiers= "const" >
<return type= "bool" >
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
<description >
2019-12-18 06:24:54 +08:00
Returns [code]true[/code] if the item at index [code]idx[/code] is disabled.
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "remove_item" >
<return type= "void" >
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
<description >
2019-12-18 06:24:54 +08:00
Removes the item at index [code]idx[/code].
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "select" >
<return type= "void" >
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
<description >
2019-12-18 06:24:54 +08:00
Selects an item by index and makes it the current item. This will work even if the item is disabled.
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "set_item_disabled" >
<return type= "void" >
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
<argument index= "1" name= "disabled" type= "bool" >
</argument>
<description >
2019-12-18 06:24:54 +08:00
Sets whether the item at index [code]idx[/code] 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.
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "set_item_icon" >
<return type= "void" >
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
2020-02-12 16:59:06 +08:00
<argument index= "1" name= "texture" type= "Texture2D" >
2017-09-13 04:42:36 +08:00
</argument>
<description >
2019-12-18 06:24:54 +08:00
Sets the icon of the item at index [code]idx[/code].
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "set_item_id" >
<return type= "void" >
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
<argument index= "1" name= "id" type= "int" >
</argument>
<description >
2019-12-18 06:24:54 +08:00
Sets the ID of the item at index [code]idx[/code].
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "set_item_metadata" >
<return type= "void" >
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
<argument index= "1" name= "metadata" type= "Variant" >
</argument>
<description >
2019-12-18 06:24:54 +08:00
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.
2017-09-13 04:42:36 +08:00
</description>
</method>
<method name= "set_item_text" >
<return type= "void" >
</return>
<argument index= "0" name= "idx" type= "int" >
</argument>
<argument index= "1" name= "text" type= "String" >
</argument>
<description >
2019-12-18 06:24:54 +08:00
Sets the text of the item at index [code]idx[/code].
2017-09-13 04:42:36 +08:00
</description>
</method>
</methods>
<members >
2019-09-24 19:34:03 +08:00
<member name= "action_mode" type= "int" setter= "set_action_mode" getter= "get_action_mode" override= "true" enum= "BaseButton.ActionMode" default= "0" />
<member name= "align" type= "int" setter= "set_text_align" getter= "get_text_align" override= "true" enum= "Button.TextAlign" default= "0" />
2019-06-29 18:38:01 +08:00
<member name= "selected" type= "int" setter= "_select_int" getter= "get_selected" default= "-1" >
2019-12-18 06:24:54 +08:00
The index of the currently selected item, or [code]-1[/code] if no item is selected.
2017-09-13 04:42:36 +08:00
</member>
2019-09-24 19:34:03 +08:00
<member name= "toggle_mode" type= "bool" setter= "set_toggle_mode" getter= "is_toggle_mode" override= "true" default= "true" />
2017-09-13 04:42:36 +08:00
</members>
<signals >
2018-04-10 16:12:42 +08:00
<signal name= "item_focused" >
2020-03-26 01:07:18 +08:00
<argument index= "0" name= "index" type= "int" >
2018-04-10 16:12:42 +08:00
</argument>
<description >
2020-08-29 23:14:34 +08:00
Emitted when the user navigates to an item using the [code]ui_up[/code] or [code]ui_down[/code] actions. The index of the item selected is passed as argument.
2018-04-10 16:12:42 +08:00
</description>
</signal>
2017-09-13 04:42:36 +08:00
<signal name= "item_selected" >
2020-03-26 01:07:18 +08:00
<argument index= "0" name= "index" type= "int" >
2017-09-13 04:42:36 +08:00
</argument>
<description >
2019-06-22 07:04:47 +08:00
Emitted when the current item has been changed by the user. The index of the item selected is passed as argument.
2017-09-13 04:42:36 +08:00
</description>
</signal>
</signals>
<constants >
</constants>
<theme_items >
2020-02-12 16:59:06 +08:00
<theme_item name= "arrow" type= "Texture2D" >
2020-02-04 15:46:01 +08:00
The arrow icon to be drawn on the right end of the button.
2017-09-13 04:42:36 +08:00
</theme_item>
2019-06-29 18:38:01 +08:00
<theme_item name= "arrow_margin" type= "int" default= "2" >
2020-02-04 15:46:01 +08:00
The horizontal space between the arrow icon and the right edge of the button.
2017-09-13 04:42:36 +08:00
</theme_item>
<theme_item name= "disabled" type= "StyleBox" >
2020-08-12 19:49:10 +08:00
[StyleBox] used when the [OptionButton] is disabled (for left-to-right layouts).
</theme_item>
<theme_item name= "disabled_mirrored" type= "StyleBox" >
[StyleBox] used when the [OptionButton] is disabled (for right-to-left layouts).
2017-09-13 04:42:36 +08:00
</theme_item>
<theme_item name= "focus" type= "StyleBox" >
2020-02-04 15:46:01 +08:00
[StyleBox] used when the [OptionButton] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect.
2017-09-13 04:42:36 +08:00
</theme_item>
<theme_item name= "font" type= "Font" >
2020-02-04 15:46:01 +08:00
[Font] of the [OptionButton]'s text.
2017-09-13 04:42:36 +08:00
</theme_item>
2019-07-09 15:13:00 +08:00
<theme_item name= "font_color" type= "Color" default= "Color( 0.88, 0.88, 0.88, 1 )" >
2020-02-04 15:46:01 +08:00
Default text [Color] of the [OptionButton].
2017-09-13 04:42:36 +08:00
</theme_item>
2020-12-08 21:11:45 +08:00
<theme_item name= "font_disabled_color" type= "Color" default= "Color( 0.9, 0.9, 0.9, 0.2 )" >
2020-02-04 15:46:01 +08:00
Text [Color] used when the [OptionButton] is disabled.
2017-09-13 04:42:36 +08:00
</theme_item>
2020-12-08 21:11:45 +08:00
<theme_item name= "font_hover_color" type= "Color" default= "Color( 0.94, 0.94, 0.94, 1 )" >
2020-02-04 15:46:01 +08:00
Text [Color] used when the [OptionButton] is being hovered.
2017-09-13 04:42:36 +08:00
</theme_item>
2020-12-26 05:45:28 +08:00
<theme_item name= "font_outline_color" type= "Color" default= "Color( 1, 1, 1, 1 )" >
The tint of text outline of the [OptionButton].
</theme_item>
2020-12-08 21:11:45 +08:00
<theme_item name= "font_pressed_color" type= "Color" default= "Color( 1, 1, 1, 1 )" >
2020-02-04 15:46:01 +08:00
Text [Color] used when the [OptionButton] is being pressed.
2017-09-13 04:42:36 +08:00
</theme_item>
2020-08-12 19:49:10 +08:00
<theme_item name= "font_size" type= "int" >
Font size of the [OptionButton]'s text.
</theme_item>
2017-09-13 04:42:36 +08:00
<theme_item name= "hover" type= "StyleBox" >
2020-08-12 19:49:10 +08:00
[StyleBox] used when the [OptionButton] is being hovered (for left-to-right layouts).
</theme_item>
<theme_item name= "hover_mirrored" type= "StyleBox" >
[StyleBox] used when the [OptionButton] is being hovered (for right-to-left layouts).
2017-09-13 04:42:36 +08:00
</theme_item>
2019-06-29 18:38:01 +08:00
<theme_item name= "hseparation" type= "int" default= "2" >
2020-02-04 15:46:01 +08:00
The horizontal space between [OptionButton]'s icon and text.
2017-09-13 04:42:36 +08:00
</theme_item>
<theme_item name= "normal" type= "StyleBox" >
2020-08-12 19:49:10 +08:00
Default [StyleBox] for the [OptionButton] (for left-to-right layouts).
</theme_item>
<theme_item name= "normal_mirrored" type= "StyleBox" >
Default [StyleBox] for the [OptionButton] (for right-to-left layouts).
2017-09-13 04:42:36 +08:00
</theme_item>
2020-12-26 05:45:28 +08:00
<theme_item name= "outline_size" type= "int" default= "0" >
The size of the text outline.
</theme_item>
2017-09-13 04:42:36 +08:00
<theme_item name= "pressed" type= "StyleBox" >
2020-08-12 19:49:10 +08:00
[StyleBox] used when the [OptionButton] is being pressed (for left-to-right layouts).
</theme_item>
<theme_item name= "pressed_mirrored" type= "StyleBox" >
[StyleBox] used when the [OptionButton] is being pressed (for right-to-left layouts).
2017-09-13 04:42:36 +08:00
</theme_item>
</theme_items>
</class>