form.openDialog¶
since 1.1.0
Open a dialog.
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
title |
string | yes | the title of the dialog |
message |
string | yes | the message of the dialog |
buttons |
table | yes | the table of buttons, each button is a table with these keys: |
Fields of buttons:
- 'label' (string): the displayed text
- 'action' (function): the function which will be called on button press
| options | number | yes | text flags like TEXT_LEFT, TEXT_CENTERED, etc. |
| wakeup | function | yes | handler called at each loop |
| paint | function | yes | paint function |
| closeWhenClickOutside | bool | yes | close the dialog when clicking outside |
Returns¶
Dialog
Examples¶
From the official Ethos documentation
local buttons = {
{label="OK", action=function() return true end},
{label="Cancel", action=function() return true end},
{label="Nothing", action=function() return false end},
}
local dialog = form.openDialog({
title="Dialog demo",
message="This is a demo to show how to use LUA Message Dialog",
width=500,
buttons=buttons,
options=TEXT_LEFT,
wakeup=function()
print("dialog wakeup ...")
end,
paint=function()
lcd.drawText(10, 10, "Text overlay!")
end,
closeWhenClickOutside=true
})
Used in¶
Real-world usage¶
Called 120 times across 6 open-source Ethos Lua projects. A few short excerpts: