Electron Dialog


Synchronous API

ShowOpenDialogSync


ShowSaveDialogSync


ShowMessageBoxSync


Asynchronous API

ShowOpenDialog


ShowSaveDialog

const template = {
  title: "Save As",
  defaultPath: myDocuments,
  properties: ["showOverwriteConfirmation"],
  filters: [
    { name: "Markdown", extensions: ["md"] },
    { name: "Plain Text", extensions: ["txt"] },
  ],
};

dialog.showSaveDialog(win, template)
.then(r => {
  if (r.canceled) console.log("File not saved");
  else console.log("File saved");
});


ShowMessageBox

const template= {
  message: "Something failed",
  buttons: ["&Cancel", "&Try Again"],
  type: "error",
  normalizeAccessKeys: true,
};

dialog.showMessageBox(win, template)
.then(r => {
  if (r.response==0) console.log("Cancelling");
  else console.log("Trying again");
});


ShowErrorBox


ShowCertificateTrustDialog


See also

Electron API for dialog


CategoryRicottone

Node/Electron/Dialog (last edited 2023-03-02 17:24:01 by DominicRicottone)