Unigine.WidgetButton Class
Inherits: | Widget |
Interface for widget button handling.
See Also#
- UnigineScript API sample <UnigineSDK>/data/samples/widgets/button_00
Example#
The following code illustrates how to create a button widget and set its parameters.
/* .. */
// event handler function
void OnButtonClicked()
{
/* .. */
return;
}
/* .. */
public override bool Init()
{
// getting a pointer to the system GUI
Gui gui = Gui.Get();
// creating a button widget and setting its caption
WidgetButton widget_button = new WidgetButton(gui, "Delete");
// setting a tooltip
widget_button.SetToolTip("Delete object(s)");
// rearranging button size
widget_button.Arrange();
// setting button position
widget_button.SetPosition(10, 10);
// setting onButtonClicked function to handle CLICKED event
widget_button.AddCallback(Gui.CALLBACK_INDEX.CLICKED, OnButtonClicked);
// adding created button widget to the system GUI
gui.AddChild(widget_button, Gui.ALIGN_OVERLAP | Gui.ALIGN_FIXED);
}
WidgetButton Class
Properties
string Text#
The button text label.
set
Sets a button text label.
set value -
Button label.
int TextAlign#
Alignment of the button label.
set
Sets alignment of the button label.
set value -
One of the GUI_ALIGN_* pre-defined variables.
string Texture#
The path to the button image texture.
set
Sets a button image texture.
set value -
Path to a texture file.
bool IsToggled#
A value indicating if the toggle button is pressed.
set
Sets a state of the toggle button.
set value -
Positive number to press the button, 0 to release it.
bool IsToggleable#
A value indicating if the button is a toggle button or a simple one. the default is 0.
set
Sets a value indicating if the button is a toggle button or a simple one.
set value -
Positive number to make the button a toggle button, 0 to make it a simple one.
int Background#
A value indicating if a background texture is rendered for the button. the default is 1.
set
Sets a value indicating if a background texture should be rendered for the button. By default, the background texture is always rendered. The default is 1.
set value -
Positive number to render a background texture, 0 not to render.
vec4 ButtonColor#
Returns the current color for the button.
set
Sets the color to be used for the button.
set value -
Four-component vector specifying the color in the RGBA format.
Members
static WidgetButton ( Gui gui, string str = 0 ) #
Constructor. Creates a button with a given label.Arguments
- Gui gui - GUI, to which the new button will belong.
- string str - Button label. This is an optional parameter.
void SetImage ( Image image ) #
Updates a button image.Arguments
- Image image - Image to set.
Image GetImage ( ) #
Returns the button image.Return value
Button image.void SetButtonColor ( vec4 color ) #
Sets the color to be used for the button.Arguments
- vec4 color - Four-component vector specifying the color in the RGBA format.
vec4 GetButtonColor ( ) #
Returns the current color for the button.Return value
Four-component vector specifying the color in the RGBA format.Last update:
2020-06-02
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)