AROYN UI LIBRARY / UI COMPONENTS
Button
Run an explicit action with a Primary or Secondary button.
Create Button#
Run an explicit action with a Primary or Secondary button.
The constructor returns a Button handle. The snippet assumes section exists, as created in Quick start.
local button = section:CreateButton({
Name = "Save preferences", Text = "Save", Variant = "Primary",
Callback = function()
local ok, info = window:SaveConfig("main")
if not ok then warn(info.Code, info.Message) end
end,
})
Open full size ↗
Open full size ↗Arguments#
| Option | Type | Default | Meaning |
|---|---|---|---|
| Text | string | Name | Button caption; separate from the row label. |
| Variant | "Primary" | "Secondary" | "Secondary" | Neutral high-contrast primary or quiet secondary style. |
| Callback | function() | nil | Called on activation. No value argument. |
Also accepts common options: Name, Description and Disabled. Button does not register Flag, Persist or Sensitive for configuration.
Manage state#
button:SetText("Save again")
print(button:GetText())
button:SetDisabled(true)Returned methods#
| Method | Returns | Behavior |
|---|---|---|
| GetText() | string | Current button caption. |
| SetText(string) | self | Changes the caption, not the row Name. |
| SetDisabled(boolean) | self | Prevents user activation without changing the caption. |
| IsDisabled() | boolean | Reads the requested disabled state. |
| Destroy() | nil | Removes this control and its subscriptions; safe to repeat. |
Behavior and limitations#
A Button has no persistent value or GetValue / SetValue contract. Flag does not make an action persistable.
Callback errors warn; the library does not promise success for your action. Disabled prevents user activation.