OptionButton

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

Category: Core

Brief Description

Button control that provides selectable options when pressed.

Properties

int selected -1

Methods

void add_icon_item ( Texture texture, String label, int id=-1 )
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
int get_item_index ( int id ) 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 )

Theme Properties

Texture arrow  
int arrow_margin 2
StyleBox disabled  
StyleBox focus  
Font font  
Color font_color Color( 0.88, 0.88, 0.88, 1 )
Color font_color_disabled Color( 0.9, 0.9, 0.9, 0.2 )
Color font_color_hover Color( 0.94, 0.94, 0.94, 1 )
Color font_color_pressed Color( 1, 1, 1, 1 )
StyleBox hover  
int hseparation 2
StyleBox normal  
StyleBox pressed  

Signals

  • item_focused ( int id )

Emitted the when user navigates to an item using the ui_up or ui_down actions. The index of the item selected is passed as argument.

  • item_selected ( int id )

Emitted when the current item has been changed by the user. The 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

Default -1
Getter get_selected()

Method Descriptions

Adds 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.

Adds 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 ( )

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.

  • void clear ( )

Clear all the items in the OptionButton.

  • int get_item_count ( ) const

Returns the amount of items in the OptionButton.

Returns the icon of the item at index idx.

  • int get_item_id ( int idx ) const

Returns the ID of the item at index idx.

  • int get_item_index ( int id ) const

Returns the index of the item with the given id.

Returns the text of the item at index idx.

Returns 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 )

Sets the icon of an item at index idx.

  • void set_item_id ( int idx, int id )

Sets the ID of an item at index idx.

  • void set_item_metadata ( int idx, Variant metadata )
  • void set_item_text ( int idx, String text )

Sets the text of an item at index idx.