Skip to content

form.openDialog

since 1.1.0

Open a dialog.

form.openDialog(title, message, buttons, options, wakeup, paint, closeWhenClickOutside)

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:
form.openDialog({width = nil, title = "@i18n(app.modules.profile_select.save_settings)@", message = "@i18n(app.modules.profile_select.save_prompt_local)@", buttons = buttons, wakeup = function() end, paint = function() end, options = TEXT_LEFT})

src/dashx/app/lib/ui.lua:765

if form and form.openDialog then
    opts.width = nil
    return form.openDialog(opts)

src/rfsuite/app/app.lua:1066

Dialog.openDialog = function (dialogParams)
  Dialog.dialog = form.openDialog(dialogParams)
end

lua/frsky/RB25_S/stab/common.lua:46