Toggle
March 4, 2015 ยท View on GitHub
Overview
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
Properties
id
Set the ID for this control so that it can be updated later. See layout library.
<toggle id="my_toggle" />
visibility
Set the visibility state using visible or invisible or gone.
<toggle visibility="gone" />
text
Set the text to be shown.
<toggle text="hello world" />
textalign
Set horizontal text alignment using left or center or right.
<toggle text="foo" textalign="right" />
icon
Set a standard control icon. See icons list of available icons.
<toggle icon="select" />
image
Set a custom image to use. Should be a path relative to the layout file.
<toggle image="img.png" />
checked
Set whether the toggle is on (true) or off (false).
<toggle checked="true" />
Styling
See the styling page for more details.
Events
onchange
Occurs when the toggle changes state.
<toggle onchange="changed" />
actions.changed = function (checked)
...
end
ontap
Occurs when the control is tapped.
<toggle text="foo" ontap="foo_tapped" />
actions.foo_tapped = function ()
...
end
onhold
Occurs when the control is held down.
<toggle text="bar" onhold="bar_held" />
actions.bar_held = function ()
...
end
ondown
Occurs when the control is pressed down.
<toggle text="hello" ondown="hello_down" />
actions.hello_down = function ()
...
end
onup
Occurs when the control released.
<toggle text="world" onup="world_up" />
actions.world_up = function ()
...
end