Input Dialog
The input dialog window allows you to take data from the user by setting input fields.
lib.inputDialog
lib.inputDialog(heading, rows, options)heading:
stringrows:
string[]ortable(array)type:
'input'or'number'or'checkbox'or'select'or'slider'or'color'or'multi-select'or'date'or'date-range'or'time'or'textarea'
options?:
table(object)allowCancel:
booleanIf true the user will not be able to cancel and close the input dialog until submitted.
Available properties per field type:
input
label:
stringdescription?:
stringplaceholder?:
stringicon?:
stringrequired?
booleandisabled?:
booleandefault?:
stringpassword?:
booleanmin?:
numbermax?:
number
number
label:
stringdescription?:
stringplaceholder?:
stringicon?:
stringrequired?
booleandisabled?:
booleandefault?:
numbermin?:
numbermax?:
number
checkbox
label:
stringchecked?:
booleandisabled?:
booleanrequired?:
boolean
select and multi-select
label:
stringoptions:
table(array)value:
stringlabel?:
string
description?:
stringplaceholder?:
stringicon?:
stringrequired?
booleandisabled?:
booleandefault?:
stringvalue of the default option.
clearable?:
boolean
slider
label:
stringplaceholder?:
stringicon?:
stringrequired?
booleandisabled?:
booleandefault?:
numbermin?:
numbermax?:
numberstep?:
number
color
label:
stringdescription?:
stringplaceholder?:
stringicon?:
stringrequired?
booleandisabled?:
booleandefault?:
stringformat?:
'hex'|'hexa'|'rgb'|'rgba'|'hsl'|'hsla';
date
label:
stringdescription?:
stringicon?:
stringrequired?
booleandisabled?:
booleandefault?:
stringortrueTrue defaults to current date
format?:
stringDate format to display in the field
clearable?:
boolean
date-range
label:
stringdescription?:
stringicon?:
stringrequired?
booleandisabled?:
booleandefault?:
[string, string]format?:
stringDate format to display in the field
clearable?:
boolean
time
label:
stringdescription?:
stringicon?:
stringrequired?
booleandisabled?:
booleandefault?:
stringformat?:
'12'or'24'clearable?:
boolean
textarea
label:
stringdescription?:
stringplaceholder?:
stringicon?:
stringrequired?
booleandisabled?:
booleandefault?:
numbermin?:
numberMinimum amount of rows the text area will take.
max?:
numberMaxmimum amount of rows the text area will take, when exceeded goes into overflow.
autosize?:
booleanIf true text area will grow with content until max rows are reached.
The callback data is promise based meaning that the thread will not continue executing until the user either sends the data or exits the popup.
The data returned will be a table (array), indexes represent the rows sent to the dialog, so if we want data from the first field that would be index 1 (0), if we want data from the third field, that would be index 3 (2), etc...
lib.closeInputDialog
Force closes the active input dialog and sets its return data as nil
lib.closeInputDialog()Usage Example
Basic
local input = lib.inputDialog('Basic dialog', {'First row', 'Second row'})
if not input then return end
print(input, input[1], input[2])
Advanced
local input = lib.inputDialog('Dialog title', {
{type = 'input', label = 'Text input', description = 'Some input description', required = true, min = 4, max = 16},
{type = 'number', label = 'Number input', description = 'Some number description', icon = 'hashtag'},
{type = 'checkbox', label = 'Simple checkbox'},
{type = 'color', label = 'Colour input', default = '#eb4034'},
{type = 'date', label = 'Date input', icon = {'far', 'calendar'}, default = true, format = "DD/MM/YYYY"}
})
print(json.encode(input))
-- Getting r, g and b values from colour picker
local r, g, b = string.match(input[4], "rgb%((%d+), (%d+), (%d+)%)")
-- Transforming unit date return to be used with Lua's os library
local date = input[5] / 1000
Last updated