AROYN UI LIBRARY / UI COMPONENTS
Toggle
Store a boolean preference with smooth track and thumb feedback.
Create Toggle#
Store a boolean preference with smooth track and thumb feedback.
The constructor returns a Toggle handle. The snippet assumes section exists, as created in Quick start.
local toggle = section:CreateToggle({
Name = "Show details", Flag = "details", Default = false,
Callback = function(value) print("Details:", value) end,
})
Open full size ↗
Open full size ↗Arguments#
| Option | Type | Default | Meaning |
|---|---|---|---|
| Default | boolean | false | Initial normalized value. |
| Callback | function(boolean) | nil | Receives the changed value. |
Also accepts common options: Name, Description, Disabled and Callback; stateful controls additionally support Flag, Persist and Sensitive.
Manage state#
toggle:SetValue(true) -- silent
toggle:SetValue(false, true) -- notify
print(toggle:GetValue())Returned methods#
| Method | Returns | Behavior |
|---|---|---|
| GetValue() | boolean | Current boolean value. |
| SetValue(value, notify?) | self | Silent by default; true calls Callback only after a changed normalized value. |
| SetDisabled(boolean) | self | Changes user availability without discarding the value. |
| IsDisabled() | boolean | Reads the requested disabled state. |
| Destroy() | nil | Removes this control and its subscriptions; safe to repeat. |
Behavior and limitations#
Default and SetValue require booleans. Construction does not invoke Callback.
Loading a saved true preference does not start an application feature by itself. Keep runtime activation explicit.