Skip to main content

Button

Example

var button = new UiButton(0, 0, 100, 30);
with (button.state) {
text = "My Button";
on_click = function() {
show_message("Button clicked!");
}
}

State reference

VariableDescriptionTypeDefault
textButton displayed textString
statusCurrent status of the buttonRealui_enum_button_status.idle
typeButton typeRealui_enum_variants.primary
text_sepDistance in px between each lineReal-1 (default spacing)
text_max_widthRow max width before going on a newlineReal-1 (no newlines by default)
padding_horizontalHorizontal button padding (in px)Real40
padding_verticalVertical button padding (in px)Real20
click_buttonWhich button to check for the clickRealmb_left
click_typeWhich mouse event to check for the clickRealui_enum_click_type.released

Methods

set_text(text, sep, max_width)

Set the text of the button, auto-resizing the container, according to the button padding

ParamDescriptionTypeDefault
textButton textString
sepDistance between each character (in px)Real-1
max_widthMax row widthReal-1

Events

on_click(component)

Called when clicking on the button. The passed argument is the component itself

Enums

EnumValues
ui_enum_button_statusidle/clicked/hover