Show native file and message dialogs. morphDialog is a native global: it needs no import and is available anywhere in app code.
const path = morphDialog.showOpen({ title: "Open note", filter: "Markdown | *.md" })
if (path !== "") {
console.log("opening", path)
}morphDialog is not alert/confirm/prompt, and it is not navigator.clipboard-style async UI. Dialogs are synchronous OS windows: the call blocks until the dialog closes, returns the chosen path or answer, and needs a live app window. The distinct name keeps Name Follows Behavior honest — browser modals are page-owned, have no title/filter options, and report cancellation as null.
morphDialog.isAvailable(): boolean
morphDialog.showOpen(options: OpenOptions): string
morphDialog.showSave(options: SaveOptions): string
morphDialog.showMessage(options: MessageOptions): boolean
morphDialog.showConfirm(options: ConfirmOptions): boolean
morphDialog.showPrompt(options: PromptOptions): string| Method | Options | Returns | Behavior |
|---|---|---|---|
isAvailable |
— | boolean |
true when a native dialog backend is installed |
showOpen |
title, filter |
string |
Selected path, or "" when cancelled |
showSave |
title, defaultName |
string |
Selected path, or "" when cancelled |
showMessage |
title, message |
boolean |
true when acknowledged with OK, false on close/cancel or unavailable |
showConfirm |
title, message |
boolean |
true for Yes/OK, false for No/Cancel or unavailable |
showPrompt |
title, message, defaultValue |
string |
Entered text, or "" when cancelled |
Every method takes exactly one options object (except isAvailable, which takes none). Missing fields default to the empty string. Values are coerced with JavaScript String(), so a number title becomes its JS text form.
showPrompt cannot distinguish "cancelled" from "submitted an empty string": both return "". Check isAvailable() before showing UI when the difference matters, or require non-empty input in app code.
| Key | Used by | Meaning |
|---|---|---|
title |
all dialogs | OS window title |
filter |
showOpen |
File filter in `"Name |
defaultName |
showSave |
Initial file name or path |
message |
showMessage, showConfirm, showPrompt |
Dialog body text |
defaultValue |
showPrompt |
Initial text in the entry field |
Only those keys are accepted. Unknown keys, computed keys, spread properties, and non-object arguments fail morph check; they never reach the runtime.
Open a file and react to cancellation:
const openNote = () => {
const path = morphDialog.showOpen({
title: "Open note",
filter: "Markdown | *.md",
})
if (path === "") {
return
}
console.log("selected", path)
}Save with a suggested name:
const saveNote = (name: string) => {
const path = morphDialog.showSave({
title: "Save note",
defaultName: name,
})
if (path !== "") {
console.log("saving to", path)
}
}Ask before a destructive action:
const deleteNote = () => {
if (!morphDialog.isAvailable()) {
return
}
const confirmed = morphDialog.showConfirm({
title: "Delete note",
message: "This cannot be undone. Delete it?",
})
if (confirmed) {
console.log("deleted")
}
}Collect a value:
const rename = () => {
const name = morphDialog.showPrompt({
title: "Rename note",
message: "New name",
defaultValue: "Untitled",
})
if (name !== "") {
console.log("renamed to", name)
}
}| Platform | Backend | Behavior |
|---|---|---|
| Linux | zenity on PATH, with DISPLAY or WAYLAND_DISPLAY, after the first window is created |
Native GTK dialogs |
| macOS / Windows | not implemented in this part | isAvailable() is false; paths and prompts return "", message boxes return false |
| Headless / before the first window | no backend | Same fallback as unsupported platforms |
The backend installs when the first app window is created. A dialog call in module-initializer code runs before that point, so it observes the fallback; call dialogs from event handlers or effects instead.
Linux arguments are passed directly to zenity with execvp — no shell is involved — so titles, filters, and paths cannot inject command syntax.
| Form | Error |
|---|---|
morphDialog.open({}) |
mx-js-member |
const open = morphDialog.showOpen |
mx-js-member |
morphDialog["showOpen"]({}) |
mx-js-member |
morphDialog.showOpen() |
mx-js-syntax |
morphDialog.showOpen("note") |
mx-js-syntax |
morphDialog.showOpen(...args) |
mx-js-syntax |
morphDialog.showOpen({ path: "/tmp" }) |
mx-js-member |
morphDialog.showOpen({ ...options }) |
mx-js-syntax |
morphDialog.showOpen({ [key]: "x" }) |
mx-js-member |
Browser alert, confirm, and prompt remain unsupported globals. Use morphDialog.showMessage, showConfirm, and showPrompt instead.