Dialogs
Explicit decisions with adaptive sizing and a blocking modal lifecycle.
Confirm a decision#
local dialog = window:Dialog({
Type = "Confirm", Title = "Reset preferences?",
Description = "Restore defaults without deleting saved profiles.",
ConfirmText = "Reset", CancelText = "Keep", OutsideDismiss = true,
OnConfirm = function()
local ok, info = window:ResetConfig()
if not ok then warn(info.Code, info.Message) end
end,
OnCancel = function(reason) print("Cancelled:", reason) end,
OnDismiss = function(reason, actionId) print(reason, actionId) end,
})
Open full size ↗
Open full size ↗Common arguments#
| Option | Type | Default | Meaning |
|---|---|---|---|
| Title | string | Required | Nonempty. |
| Description | string | "" | Wrapped text; long content scrolls. |
| Type | Alert | Confirm | Custom | Alert | Determines actions. |
| Cancelable | boolean | false for Alert; true otherwise | Permits user cancellation and Escape. |
| OutsideDismiss | boolean | false | True requires Cancelable=true. |
| OnCancel | function(reason)? | nil | Cancellation, including programmatic/lifecycle closing. |
| OnDismiss | function(reason, actionId)? | nil | After panel removal. |
Type-specific arguments#
| Type | Options | Callbacks |
|---|---|---|
| Alert | ButtonText="OK" | OnAcknowledge() |
| Confirm | CancelText="Cancel", ConfirmText="Confirm" | OnConfirm() |
| Custom | Actions: 1–3 entries with unique Id, Text, optional Primary=false | Each action has optional Callback() |
window:Dialog({Type = "Alert", Title = "Saved", ButtonText = "OK",
OnAcknowledge = function() print("Acknowledged") end})
window:Dialog({Type = "Custom", Title = "Choose an action", Actions = {
{Id = "save", Text = "Save", Primary = true, Callback = function() print("Save") end},
{Id = "skip", Text = "Skip", Callback = function() print("Skip") end},
}})Returned methods#
| Member | Returns | Meaning |
|---|---|---|
| Id | string | Generated request identifier. |
| GetState() | string | Queued / Open / Closing / Closed. |
| GetDismissReason() | string? | Reason after closing. |
| GetAction() | string? | acknowledge, confirm, cancel, custom Id or nil. |
| Close(reason?) | self | Default programmatic; never implicitly confirms. |
Queue and input gate#
Only one dialog is visible, with up to 64 FIFO requests waiting. Open includes the entry animation. The background remains blocked through the 160ms exit and queue handoff. Modal entry closes popups, ends Slider drag, releases text focus, cancels key capture and suspends shortcuts. Desired disabled state is preserved.
Callbacks and cancellation#
A deliberate action is fixed before its callback runs. OnConfirm, OnAcknowledge or an action Callback runs immediately once, not after the exit tween. OnDismiss runs after removal. Programmatic Close, Escape, outside click and lifecycle cancellation invoke OnCancel, never confirmation.
| Reason | Meaning |
|---|---|
| action / cancel | Explicit action or cancel button. |
| escape / outside | Cancelable keyboard/outside interaction. |
| programmatic | Default Close(). |
| page_changed / minimized / hidden / input_blocked / destroyed | Owner lifecycle. |
| overflow | Queue full. |
| Custom string | Provided to Close(reason). |
Adaptive layout#
Panels use measured, wrapped content and viewport bounds. Long descriptions scroll while action buttons remain accessible. Narrow screens stack actions; short landscape can use a row when each action fits. A recommended minimum safe area is 280×190; extremely small viewports cannot show all text at once.