Components / Layers
u:dialog
A question the page asks and the person answers: title, message, an input and actions.
The code
root:child(u:dialog("unsaved", {
title = "Save changes to notes.md?",
message = "Your changes will be lost if you do not save them.",
actions = { { key = "drop", title = "Don't Save", danger = true }, { key = "save", title = "Save", primary = true } },
}))
What it does
A question the page asks and the person answers: title, message, an input ({ value, hint, label }: the answer is typed) and actions ({ key, title, primary, danger }, the last drawn last). Enter does the primary one (the first, where none is); escape and a click on the scrim give up. The answer is { kind = "answer", key = <the action's>, value = <the text> }, with no key for giving up: the page that keeps what it asks of the person stops drawing the dialog on any answer.