Callbacks
Separate value changes, explicit actions and key activation.
A value callback#
local amount = section:CreateSlider({
Name = "Amount", Min = 0, Max = 100, Step = 5, Default = 40,
Callback = function(value) print("Changed:", value) end,
})
amount:SetValue(55) -- silent update
amount:SetValue(60, true) -- invokes Callback once
amount:SetValue(60, true) -- same normalized value: no callbackCallback signatures#
| Control | Signature | When |
|---|---|---|
| Button | Callback() | Explicit button action. |
| Toggle | Callback(boolean) | Changed value from interaction or notifying setter. |
| TextInput | Callback(string) | Eligible FocusLost commit; repeated strings can be submitted. |
| Slider | Callback(number) | Changed normalized value. |
| Dropdown · single | Callback(string?) | Changed selection; nil means no selection. |
| Dropdown · multi | Callback({string}) | Changed selections; independent array in Options order. |
| Keybind | Callback(Enum.KeyCode?) | Rebinding or a notifying mode change; separate from activation. |
| ColorPicker | Callback(Color3) | Changed RGB value. |
Shortcut activation#
Keybind has a separate OnActivate(active, key, mode). A silent binding change may still release an active key using OnActivate(false). LoadConfig and ResetConfig silence both ordinary callbacks and activation while applying state; InvokeCallbacks=true opts into ordinary changed callbacks only.
Keep controllers explicit#
Do not make a restored true preference automatically start an automation loop. Load preferences, inspect values, then let a deliberate action enable your runtime. Protect operations that can destroy their own control; do not continue using a dead handle after a callback.
Error handling#
The library wraps user handlers in pcall and warns on failure. That isolates the UI but does not undo partial changes in your controller. Treat failed operations as failures rather than swallowing errors or presenting a success toast.