ButtonArray

Inherits: Control < CanvasItem < Node < Object

Inherited By: HButtonArray, VButtonArray

Category: Core

Brief Description

Array of Buttons.

Member Functions

void add_button ( String text, String tooltip=”” )
void add_icon_button ( Texture icon, String text=”“, String tooltip=”” )
void clear ( )
void erase_button ( int button_idx )
int get_button_count ( ) const
Texture get_button_icon ( int button_idx ) const
String get_button_text ( int button_idx ) const
String get_button_tooltip ( int button_idx ) const
int get_hovered ( ) const
int get_selected ( ) const
bool is_flat ( ) const
void set_button_icon ( int button_idx, Texture icon )
void set_button_text ( int button_idx, String text )
void set_button_tooltip ( int button_idx, String text )
void set_flat ( bool enabled )
void set_selected ( int button_idx )

Signals

  • button_selected ( int button_idx )

A button has been selected, its index is given as the argument.

Numeric Constants

  • ALIGN_BEGIN = 0 — Align buttons at the beginning.
  • ALIGN_CENTER = 1 — Align buttons in the middle.
  • ALIGN_END = 2 — Align buttons at the end.
  • ALIGN_FILL = 3 — Spread the buttons, but keep them small.
  • ALIGN_EXPAND_FILL = 4 — Spread the buttons, but expand them.

Description

Array of Buttons. A ButtonArray is useful to have an array of buttons laid out vertically or horizontally. Only one button can be selected, and is referenced by its index in the array (first button is 0, second button is 1, etc.).

This is useful e.g. for joypad-friendly interfaces and option menus.

Member Function Description

Append a new button to the array, with the specified text.

Append a new button to the array, with the specified icon and text.

  • void clear ( )

Remove all buttons from the array.

  • void erase_button ( int button_idx )

Remove the specified button in the array.

  • int get_button_count ( ) const

Return the amount of buttons in the array.

  • Texture get_button_icon ( int button_idx ) const

Return the icon of the specified button.

  • String get_button_text ( int button_idx ) const

Return the text of the specified button.

  • String get_button_tooltip ( int button_idx ) const
  • int get_hovered ( ) const

Return the index of the currently hovered button in the array.

  • int get_selected ( ) const

Return the index of the currently selected button in the array.

  • bool is_flat ( ) const
  • void set_button_icon ( int button_idx, Texture icon )

Set the icon of the specified button.

  • void set_button_text ( int button_idx, String text )

Define the text of the specified button.

  • void set_button_tooltip ( int button_idx, String text )
  • void set_flat ( bool enabled )
  • void set_selected ( int button_idx )

Select a button in the array based on the given index.