! Load dialog configuration without presenting (:load)
Declaration
confirmed, selections = dlg:load()
Returns
- confirmed
Boolean. Whether the Submit button was pressed. Here it will always return false. - selections
Table. A key-value table mapped by option labels.
Notes
Load the dialog configuration without presenting it. If there is no saved configuration, default values are loaded.
Example
local dlg = dialog()
--
dlg:set_config('test')
dlg:set_timeout(30)
dlg:add_label('Simple demo')
dlg:add_range('HP', {0, 1000, 1}, 300)
dlg:add_input('Account', 'ccc')
dlg:add_input('Password', 'aaaa')
dlg:add_picker('Gender', {'Male', 'Female', 'Unknown'}, 'Male')
dlg:add_switch('Are you abnormal?', false)
dlg:add_checkbox('Favorite games', {'Overwatch', 'World of Warcraft', 'Hearthstone'}, {'Overwatch', 'World of Warcraft'})
dlg:add_radio('Most favorite game', {'Overwatch', 'World of Warcraft', 'Hearthstone'}, 'World of Warcraft')
--
local _, selects
--
if (utils.is_launch_via_app()) then
_, selects = dlg:show() -- show when launched from the app
else
_, selects = dlg:load() -- otherwise do not present
end
--
print("Account", selects["Account"])
print("Password", selects["Password"])
print("Gender", selects["Gender"])
print("HP", selects["HP"])
--
if (selects['Are you abnormal?']) then
print("You admitted you are abnormal")
else
print("You did not admit you are abnormal")
end
--
print("Your favorite games")
for _, gamename in ipairs(selects['Favorite games']) do
print(gamename)
end
--
print("Your most favorite game:"..selects["Most favorite game"])
--
sys.alert(print.out())
Note: Uses utils.is_launch_via_app
, sys.alert
, print
, print.out