OptionButton

    Category: Core

    Button control that provides selectable options when pressed.

    Properties

    Theme Properties

    • item_focused ( ID )

    This signal is emitted when user navigated to an item using or 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.

    Method Descriptions

    • void add_icon_item ( texture, String label, id=-1 )

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


    • int get_item_count ( ) const

    Returns the amount of items in the OptionButton.


    • get_item_icon ( int idx ) const

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


    • get_item_id ( int idx ) const

    • get_item_index ( int id ) const

    Returns the index of the item with the given .


    • get_item_metadata ( int idx ) const

    • get_item_text ( int idx ) const

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


    Returns the contained in this button.


    • int get_selected_id ( ) const

    • get_selected_metadata ( ) const

    • bool is_item_disabled ( idx ) const

    • void remove_item ( int idx )

    • void select ( idx )

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


    • void set_item_disabled ( int idx, disabled )

    • void set_item_icon ( int idx, texture )

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


    • void set_item_id ( int idx, id )

    • void set_item_metadata ( int idx, metadata )

    • void set_item_text ( int idx, text )

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