OptionButton

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

Category: Core

Brief Description

Button control that provides selectable options when pressed.

Properties

intselected

Methods

voidadd_icon_item ( Texture texture, String label, int id=-1 )
voidadd_item ( String label, int id=-1 )
voidadd_separator ( )
voidclear ( )
intget_item_count ( ) const
Textureget_item_icon ( int idx ) const
intget_item_id ( int idx ) const
intget_item_index ( int id ) const
Variantget_item_metadata ( int idx ) const
Stringget_item_text ( int idx ) const
PopupMenuget_popup ( ) const
intget_selected_id ( ) const
Variantget_selected_metadata ( ) const
boolis_item_disabled ( int idx ) const
voidremove_item ( int idx )
voidselect ( int idx )
voidset_item_disabled ( int idx, bool disabled )
voidset_item_icon ( int idx, Texture texture )
voidset_item_id ( int idx, int id )
voidset_item_metadata ( int idx, Variant metadata )
voidset_item_text ( int idx, String text )

Theme Properties

Texturearrow
intarrow_margin
StyleBoxdisabled
StyleBoxfocus
Fontfont
Colorfont_color
Colorfont_color_disabled
Colorfont_color_hover
Colorfont_color_pressed
StyleBoxhover
inthseparation
StyleBoxnormal
StyleBoxpressed

Signals

  • item_focused ( 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.


  • item_selected ( 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

Getterget_selected()

Method Descriptions

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.


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

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 )

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 )

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