Slider
Choose a finite number within bounds and quantize it to a step.
Create Slider#
Choose a finite number within bounds and quantize it to a step.
The constructor returns a Slider handle. The snippet assumes section exists, as created in Quick start.
local slider = section:CreateSlider({
Name = "Volume", Flag = "volume", Min = 0, Max = 100, Step = 5,
Default = 40, Suffix = "%",
Callback = function(value) print("Volume:", value) end,
})
Open full size ↗Arguments#
| Option | Type | Default | Meaning |
|---|---|---|---|
| Min | number | 0 | Finite lower bound. |
| Max | number | 100 | Finite upper bound, at least Min. |
| Step | number | 1 | Finite positive interval. |
| Default | number | Min | Clamped and step-normalized. |
| Suffix | string | "" | Display suffix, such as %. |
| Callback | function(number) | nil | Receives the normalized value. |
Also accepts common options: Name, Description, Disabled and Callback; stateful controls additionally support Flag, Persist and Sensitive.
Manage state#
slider:SetValue(58, true) -- normalized to a step in bounds
print(slider:GetValue())
slider:SetDisabled(true)Returned methods#
| Method | Returns | Behavior |
|---|---|---|
| GetValue() | number | Current number 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#
Max must be at least Min; Step must be greater than zero, and (Max-Min)/Step must remain below 1e15. NaN and infinity are rejected.
Modal opening, hide, minimize, disable or destruction cancel an active drag and restore scrolling ownership.
Mouse/touch support exists in the implementation. Real touch behavior is still pending device verification; mock input tests do not establish it.
Steps are rounded to the nearest interval from Min, with halfway values rounding upward. Exact Min and Max remain reachable even when the range is not divisible by Step. An invalid setter asserts before changing the value.