-
Notifications
You must be signed in to change notification settings - Fork 0
Ui XML Button
BlackTower edited this page Jul 28, 2022
·
2 revisions
Ui XML Reference\Button
A button which can can be hooked up to run a lua function or change a XML state on click. By default, new buttons use a padding of 12 and btn_green
as their background image. This frame type has a default size of 0 and expands to fit any children. Commonly supports a child text frame as button text.
<Button width="200" height="100">
<Text text="Button" />
</Button>
This XML produces the following UI (shown in the UI previewer):
A button
Value type: boolean
Supports data binding
The enabled status for the button frame, where true
is enabled and false
is disabled. Disabled buttons are grayed out and do not register events.
<Button width="200" height="100" enable="false">
<Text text="Button" />
</Button>
Value type: string
The bound onClick function for the button.
<VStack xmlns:bind="https://platform.wildsky.dev/xml/ui/bind">
<!-- Declare initial state values. -->
<State name="red" booleanValue="false" />
<!-- Show different background images depending on the state value and flip state value when clicked. -->
<Button bind:backgroundImage="'btn_' .. (state.red and 'red' or 'blue')" bind:onClick="state.red = not state.red">
<Text text="switch color" />
</Button>
<Text bind:text="state.red and 'red' or 'blue'" />
</VStack>