W3cubDocs

/Godot 3.0

OptionButton

Inherits: Button < BaseButton < Control < CanvasItem < Node < Object

Category: Core

Brief Description

Button control that provides selectable options when pressed.

Member Functions

void add_icon_item ( Texture texture, String label, int id )
void add_item ( String label, int id=-1 )
void add_separator ( )
void clear ( )
int get_item_count ( ) const
Texture get_item_icon ( int idx ) const
int get_item_id ( int idx ) const
Variant get_item_metadata ( int idx ) const
String get_item_text ( int idx ) const
PopupMenu get_popup ( ) const
int get_selected_id ( ) const
Variant get_selected_metadata ( ) const
bool is_item_disabled ( int idx ) const
void remove_item ( int idx )
void select ( int idx )
void set_item_disabled ( int idx, bool disabled )
void set_item_icon ( int idx, Texture texture )
void set_item_id ( int idx, int id )
void set_item_metadata ( int idx, Variant metadata )
void set_item_text ( int idx, String text )

Signals

item_selected ( 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).

Member Variables

int selected

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

void add_icon_item ( Texture texture, String label, 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.

void add_item ( String label, 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.

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.

void clear ( )

Clear all the items in the OptionButton.

int get_item_count ( ) const

Return the amount of items in the OptionButton.

Texture get_item_icon ( int idx ) const

Return the icon of the item at index “idx”.

int get_item_id ( int idx ) const

Return the ID of the item at index “idx”.

Variant get_item_metadata ( int idx ) const

String get_item_text ( int idx ) const

Return the text of the item at index “idx”.

PopupMenu get_popup ( ) const

Return the PopupMenu contained in this button.

int get_selected_id ( ) const

Variant get_selected_metadata ( ) const

bool is_item_disabled ( int idx ) const

void remove_item ( int idx )

void select ( int idx )

Select an item by index and make it the current item.

void set_item_disabled ( int idx, bool disabled )

void set_item_icon ( int idx, Texture texture )

Set the icon of an item at index “idx”.

void set_item_id ( int idx, int id )

Set the ID of an item at index “idx”.

void set_item_metadata ( int idx, Variant metadata )

void set_item_text ( int idx, String text )

Set the text of an item at index “idx”.

© 2014–2018 Juan Linietsky, Ariel Manzur, Godot Engine contributors
Licensed under the MIT License.
http://docs.godotengine.org/en/3.0/classes/class_optionbutton.html