Skip to content

Latest commit

 

History

History
60 lines (47 loc) · 1.21 KB

File metadata and controls

60 lines (47 loc) · 1.21 KB

Dialogs

app.dialog provides native file and message dialogs by shelling out to each OS's built-in tools (no extra runtime dependencies):

  • Windows: PowerShell + System.Windows.Forms
  • macOS: osascript
  • Linux: zenity or kdialog (whichever is available)

openFile

const files = await app.dialog.openFile({
  title: "Select a file",
  defaultPath: app.paths.documents(),
  filters: [{ name: "Images", extensions: ["png", "jpg", "jpeg"] }],
  multiple: false,
});
// files: string[] | null (null if cancelled)

saveFile

const path = await app.dialog.saveFile({
  title: "Save report",
  defaultPath: "report.json",
  filters: [{ name: "JSON", extensions: ["json"] }],
});
// path: string | null

openFolder

const folder = await app.dialog.openFolder({ title: "Choose a folder" });
// folder: string | null

message

await app.dialog.message({
  title: "Done",
  message: "Export finished successfully.",
  type: "info", // "info" | "warning" | "error"
});

confirm

const ok = await app.dialog.confirm({
  title: "Delete file?",
  message: "This cannot be undone.",
});
// ok: boolean

All dialog functions are async and resolve once the user closes the dialog.