2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2020-02-01 01:03:48 +00:00
<class name= "OptionButton" inherits= "Button" version= "4.0" >
2017-09-12 20:42:36 +00: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-23 21:34:28 +00:00
See also [BaseButton] which contains common properties and methods associated with this node.
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
</tutorials>
<methods >
<method name= "add_icon_item" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "texture" type= "Texture2D" />
<argument index= "1" name= "label" type= "String" />
<argument index= "2" name= "id" type= "int" default= "-1" />
2017-09-12 20:42:36 +00:00
<description >
2019-12-17 22:24:54 +00: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-12 20:42:36 +00:00
</description>
</method>
<method name= "add_item" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "label" type= "String" />
<argument index= "1" name= "id" type= "int" default= "-1" />
2017-09-12 20:42:36 +00:00
<description >
2019-12-17 22:24:54 +00: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-12 20:42:36 +00:00
</description>
</method>
<method name= "add_separator" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2017-09-12 20:42:36 +00:00
<description >
2019-06-21 23:04:47 +00: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-12 20:42:36 +00:00
</description>
</method>
<method name= "clear" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2017-09-12 20:42:36 +00:00
<description >
2019-12-17 22:24:54 +00:00
Clears all the items in the [OptionButton].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_item_icon" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Texture2D" />
<argument index= "0" name= "idx" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-06-21 23:04:47 +00:00
Returns the icon of the item at index [code]idx[/code].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_item_id" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
<argument index= "0" name= "idx" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-05-24 02:15:43 +00:00
Returns the ID of the item at index [code]idx[/code].
2019-01-28 15:31:24 +00:00
</description>
</method>
2019-02-16 13:40:52 +00:00
<method name= "get_item_index" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
<argument index= "0" name= "id" type= "int" />
2019-02-16 13:40:52 +00:00
<description >
2019-05-24 02:15:43 +00:00
Returns the index of the item with the given [code]id[/code].
2019-02-16 13:40:52 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "get_item_metadata" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Variant" />
<argument index= "0" name= "idx" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-12-17 22:24:54 +00: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-12 20:42:36 +00:00
</description>
</method>
<method name= "get_item_text" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "String" />
<argument index= "0" name= "idx" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-06-21 23:04:47 +00:00
Returns the text of the item at index [code]idx[/code].
2017-09-12 20:42:36 +00:00
</description>
</method>
2017-12-25 15:24:10 +00:00
<method name= "get_popup" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "PopupMenu" />
2017-12-25 15:24:10 +00:00
<description >
2019-05-24 02:15:43 +00:00
Returns the [PopupMenu] contained in this button.
2021-10-10 19:28:56 +00:00
[b]Warning:[/b] This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their [member Window.visible] property.
2017-12-25 15:24:10 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "get_selected_id" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-12-17 22:24:54 +00:00
Returns the ID of the selected item, or [code]0[/code] if no item is selected.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_selected_metadata" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Variant" />
2017-09-12 20:42:36 +00:00
<description >
2019-12-17 22:24:54 +00:00
Gets the metadata of the selected item. Metadata for items can be set using [method set_item_metadata].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "is_item_disabled" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "idx" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-12-17 22:24:54 +00:00
Returns [code]true[/code] if the item at index [code]idx[/code] is disabled.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "remove_item" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "idx" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-12-17 22:24:54 +00:00
Removes the item at index [code]idx[/code].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "select" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "idx" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-12-17 22:24:54 +00:00
Selects an item by index and makes it the current item. This will work even if the item is disabled.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "set_item_disabled" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "idx" type= "int" />
<argument index= "1" name= "disabled" type= "bool" />
2017-09-12 20:42:36 +00:00
<description >
2019-12-17 22:24:54 +00: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-12 20:42:36 +00:00
</description>
</method>
<method name= "set_item_icon" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "idx" type= "int" />
<argument index= "1" name= "texture" type= "Texture2D" />
2017-09-12 20:42:36 +00:00
<description >
2019-12-17 22:24:54 +00:00
Sets the icon of the item at index [code]idx[/code].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "set_item_id" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "idx" type= "int" />
<argument index= "1" name= "id" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-12-17 22:24:54 +00:00
Sets the ID of the item at index [code]idx[/code].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "set_item_metadata" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "idx" type= "int" />
<argument index= "1" name= "metadata" type= "Variant" />
2017-09-12 20:42:36 +00:00
<description >
2019-12-17 22:24:54 +00: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-12 20:42:36 +00:00
</description>
</method>
<method name= "set_item_text" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "idx" type= "int" />
<argument index= "1" name= "text" type= "String" />
2017-09-12 20:42:36 +00:00
<description >
2019-12-17 22:24:54 +00:00
Sets the text of the item at index [code]idx[/code].
2017-09-12 20:42:36 +00:00
</description>
</method>
</methods>
<members >
2021-12-02 19:38:49 +00:00
<member name= "action_mode" type= "int" setter= "set_action_mode" getter= "get_action_mode" overrides= "BaseButton" enum= "BaseButton.ActionMode" default= "0" />
2021-11-25 02:58:47 +00:00
<member name= "alignment" type= "int" setter= "set_text_alignment" getter= "get_text_alignment" overrides= "Button" enum= "HorizontalAlignment" default= "0" />
2021-12-11 15:13:16 +00:00
<member name= "item_count" type= "int" setter= "set_item_count" getter= "get_item_count" default= "0" >
The number of items to select from.
</member>
2019-06-29 10:38:01 +00:00
<member name= "selected" type= "int" setter= "_select_int" getter= "get_selected" default= "-1" >
2019-12-17 22:24:54 +00:00
The index of the currently selected item, or [code]-1[/code] if no item is selected.
2017-09-12 20:42:36 +00:00
</member>
2021-12-02 19:38:49 +00:00
<member name= "toggle_mode" type= "bool" setter= "set_toggle_mode" getter= "is_toggle_mode" overrides= "BaseButton" default= "true" />
2017-09-12 20:42:36 +00:00
</members>
<signals >
2018-04-10 08:12:42 +00:00
<signal name= "item_focused" >
2021-07-30 13:28:05 +00:00
<argument index= "0" name= "index" type= "int" />
2018-04-10 08:12:42 +00:00
<description >
2020-08-29 15:14:34 +00: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 08:12:42 +00:00
</description>
</signal>
2017-09-12 20:42:36 +00:00
<signal name= "item_selected" >
2021-07-30 13:28:05 +00:00
<argument index= "0" name= "index" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-06-21 23:04:47 +00:00
Emitted when the current item has been changed by the user. The index of the item selected is passed as argument.
2017-09-12 20:42:36 +00:00
</description>
</signal>
</signals>
<theme_items >
2021-08-04 16:54:41 +00:00
<theme_item name= "font_color" data_type= "color" type= "Color" default= "Color(0.88, 0.88, 0.88, 1)" >
2020-02-04 07:46:01 +00:00
Default text [Color] of the [OptionButton].
2017-09-12 20:42:36 +00:00
</theme_item>
2021-08-04 16:54:41 +00:00
<theme_item name= "font_disabled_color" data_type= "color" type= "Color" default= "Color(0.9, 0.9, 0.9, 0.2)" >
2020-02-04 07:46:01 +00:00
Text [Color] used when the [OptionButton] is disabled.
2017-09-12 20:42:36 +00:00
</theme_item>
2021-10-26 14:28:12 +00:00
<theme_item name= "font_focus_color" data_type= "color" type= "Color" default= "Color(0.94, 0.94, 0.94, 1)" >
Text [Color] used when the [OptionButton] is focused. Only replaces the normal text color of the button. Disabled, hovered, and pressed states take precedence over this color.
</theme_item>
2021-08-04 16:54:41 +00:00
<theme_item name= "font_hover_color" data_type= "color" type= "Color" default= "Color(0.94, 0.94, 0.94, 1)" >
2020-02-04 07:46:01 +00:00
Text [Color] used when the [OptionButton] is being hovered.
2017-09-12 20:42:36 +00:00
</theme_item>
2021-08-04 16:54:41 +00:00
<theme_item name= "font_outline_color" data_type= "color" type= "Color" default= "Color(1, 1, 1, 1)" >
2020-12-25 21:45:28 +00:00
The tint of text outline of the [OptionButton].
</theme_item>
2021-08-04 16:54:41 +00:00
<theme_item name= "font_pressed_color" data_type= "color" type= "Color" default= "Color(1, 1, 1, 1)" >
2020-02-04 07:46:01 +00:00
Text [Color] used when the [OptionButton] is being pressed.
2017-09-12 20:42:36 +00:00
</theme_item>
2021-12-01 18:02:20 +00:00
<theme_item name= "arrow_margin" data_type= "constant" type= "int" default= "2" >
The horizontal space between the arrow icon and the right edge of the button.
</theme_item>
<theme_item name= "hseparation" data_type= "constant" type= "int" default= "2" >
The horizontal space between [OptionButton]'s icon and text.
</theme_item>
<theme_item name= "outline_size" data_type= "constant" type= "int" default= "0" >
The size of the text outline.
</theme_item>
<theme_item name= "font" data_type= "font" type= "Font" >
[Font] of the [OptionButton]'s text.
</theme_item>
2021-08-04 16:54:41 +00:00
<theme_item name= "font_size" data_type= "font_size" type= "int" >
2020-08-12 11:49:10 +00:00
Font size of the [OptionButton]'s text.
</theme_item>
2021-12-01 18:02:20 +00:00
<theme_item name= "arrow" data_type= "icon" type= "Texture2D" >
The arrow icon to be drawn on the right end of the button.
</theme_item>
<theme_item name= "disabled" data_type= "style" type= "StyleBox" >
[StyleBox] used when the [OptionButton] is disabled (for left-to-right layouts).
</theme_item>
<theme_item name= "disabled_mirrored" data_type= "style" type= "StyleBox" >
[StyleBox] used when the [OptionButton] is disabled (for right-to-left layouts).
</theme_item>
<theme_item name= "focus" data_type= "style" type= "StyleBox" >
2021-11-20 16:43:34 +00:00
[StyleBox] used when the [OptionButton] is focused. The [code]focus[/code] [StyleBox] is displayed [i]over[/i] the base [StyleBox], so a partially transparent [StyleBox] should be used to ensure the base [StyleBox] remains visible. A [StyleBox] that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a [StyleBoxEmpty] resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
2021-12-01 18:02:20 +00:00
</theme_item>
2021-08-04 16:54:41 +00:00
<theme_item name= "hover" data_type= "style" type= "StyleBox" >
2020-08-12 11:49:10 +00:00
[StyleBox] used when the [OptionButton] is being hovered (for left-to-right layouts).
</theme_item>
2021-08-04 16:54:41 +00:00
<theme_item name= "hover_mirrored" data_type= "style" type= "StyleBox" >
2020-08-12 11:49:10 +00:00
[StyleBox] used when the [OptionButton] is being hovered (for right-to-left layouts).
2017-09-12 20:42:36 +00:00
</theme_item>
2021-08-04 16:54:41 +00:00
<theme_item name= "normal" data_type= "style" type= "StyleBox" >
2020-08-12 11:49:10 +00:00
Default [StyleBox] for the [OptionButton] (for left-to-right layouts).
</theme_item>
2021-08-04 16:54:41 +00:00
<theme_item name= "normal_mirrored" data_type= "style" type= "StyleBox" >
2020-08-12 11:49:10 +00:00
Default [StyleBox] for the [OptionButton] (for right-to-left layouts).
2017-09-12 20:42:36 +00:00
</theme_item>
2021-08-04 16:54:41 +00:00
<theme_item name= "pressed" data_type= "style" type= "StyleBox" >
2020-08-12 11:49:10 +00:00
[StyleBox] used when the [OptionButton] is being pressed (for left-to-right layouts).
</theme_item>
2021-08-04 16:54:41 +00:00
<theme_item name= "pressed_mirrored" data_type= "style" type= "StyleBox" >
2020-08-12 11:49:10 +00:00
[StyleBox] used when the [OptionButton] is being pressed (for right-to-left layouts).
2017-09-12 20:42:36 +00:00
</theme_item>
</theme_items>
</class>