Input dialog
A multi-field form, keyboard-driven and async — await the submitted values in one call.
A multi-field form, keyboard-driven and async — await the submitted values in one call.
lib.inputDialog shows a form and blocks until the user submits or cancels. It returns an
ordered array of values — or nil if cancelled.
local result = lib.inputDialog('Rename', {
{ type = 'text', label = 'New name', required = true, placeholder = 'e.g. Night pack' },
})
if result then rename(result[1]) endlib.inputDialog(heading, rows) — heading is the form title, rows is the list of fields.
Returns an array where result[i] is field i's value, or nil if cancelled. A plain
string row is shorthand for { type = 'text', label = <string> }.
| Type | Detail |
|---|---|
text | Free text. password = true masks it. |
number | Numeric, min / max / step. Returns a string — use tonumber. |
select | Dropdown from options[] ({ value, label }); returns option.value. |
checkbox | Boolean toggle; returns true / false. |
slider | min / max / step — more visual than number. |
color | Color picker; returns a color string. |
textpassword = true masks it.numbermin / max / step. Returns a string — use tonumber.selectoptions[] ({ value, label }); returns option.value.checkboxtrue / false.slidermin / max / step — more visual than number.colorEach row supports: label (required), placeholder?, default?, required?, disabled?, min?, max?, step?, options?.
local result = lib.inputDialog('Configure', {
{ type = 'select', label = 'Color', required = true, options = {
{ value = 'red', label = 'Red' },
{ value = 'blue', label = 'Blue' },
}},
{ type = 'checkbox', label = 'Visible', default = true },
{ type = 'slider', label = 'Volume', min = 0, max = 100, step = 5, default = 50 },
})
if result then
local color, visible, volume = result[1], result[2], tonumber(result[3])
endlib.closeInputDialog() closes the active dialog from code (resolves as a cancel).
result == nil means cancelled; a submitted empty field is '', not nil. number and slider come back as strings — tonumber them. required is front-only, so re-validate in Lua. One dialog at a time.