Toggles are buttons that can have two states (on or off).
<toggle text="change me!" checked="true" onchange="foobar" />
actions.changed = function (checked)
print("you changed the toggle state to " .. checked);
end
Set the ID for this control so that it can be updated later. See layout library.
<toggle id="my_toggle" />
Set the visibility state using visible
or invisible
or gone
.
<toggle visibility="gone" />
Set the text to be shown.
<toggle text="hello world" />
Set horizontal text alignment using left
or center
or right
.
<toggle text="foo" textalign="right" />
Set a standard control icon. See icons list of available icons.
<toggle icon="select" />
Set a custom image to use. Should be a path relative to the layout file.
<toggle image="img.png" />
Set whether the toggle is on (true
) or off (false
).
<toggle checked="true" />
See the styling page for more details.
Occurs when the toggle changes state.
<toggle onchange="changed" />
actions.changed = function (checked)
...
end
Occurs when the control is tapped.
<toggle text="foo" ontap="foo_tapped" />
actions.foo_tapped = function ()
...
end
Occurs when the control is held down.
<toggle text="bar" onhold="bar_held" />
actions.bar_held = function ()
...
end
Occurs when the control is pressed down.
<toggle text="hello" ondown="hello_down" />
actions.hello_down = function ()
...
end
Occurs when the control released.
<toggle text="world" onup="world_up" />
actions.world_up = function ()
...
end