Dialog

Native popups for messages, errors, confirmations, and file explorer operations.

Methods

Show Open Dialog

Shows an open file dialog.

await window.deskifier.dialog.showOpen({ arguments })

Arguments

  • title String (Optional)
    A title for the dialog box.

  • defaultPath String (Optional)

    Which directory the file explorer will open on.

  • buttonLabel String (Optional)

    Custom label for the confirmation button. A default label will be used if empty.

  • filters Array Of Electron.FileFilter (Optional)
    Optionally filter files to open by.

  • openFile Boolean (Optional)
    Allows files to be selected.

  • openDirectory Boolean (Optional)
    Allow directories to be selected.

  • multiSelections Boolean (Optional)
    Allow multiple paths to be selected.

  • showHiddenFiles Boolean (Optional)
    Show hidden files in dialog.

  • createDirectory Boolean macOS (Optional)
    Allow creating new directories from dialog.

  • promptToCreate Boolean Windows (Optional)
    Prompt for creation if the file path entered in the dialog does not exist. This does not actually create the file at the path but allows non-existent paths to be returned that should be created by the application.

  • treatPackageAsDirectory Boolean macOS (Optional)
    Treat packages, such as .app folders as a directory instead of a file.

  • dontAddToRecent Boolean Windows (Optional)
    Do not add the item being opened to the recent documents list.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • canceled Boolean
    Whether or not the dialog was canceled.
  • filePaths Array of Strings
    An array of file paths chosen by the user. If the dialog is cancelled this will be an empty array.

Example

const dialogOptions = {
    filters: [
        { name: 'Images', extensions: ['jpg', 'png', 'gif'] },
        { name: 'Movies', extensions: ['mkv', 'avi', 'mp4'] },
        { name: 'Custom File Type', extensions: ['as'] },
        { name: 'All Files', extensions: ['*'] }      
    ],
    multiSelections: true
};

const result = await window.deskifier.dialog.showOpen(dialogOptions);

console.log(result.filePaths)
//["C:\\Users\\Example\\Path.jpg", "C:\\Users\\Example\\Path2.jpg"]

Show Save Dialog

Shows a save file dialog.

await window.deskifier.dialog.showSave({ arguments })

Arguments

  • title String (Optional)
    A title for the dialog box.

  • defaultPath String (Optional)

    Absolute directory path, absolute file path, or file name to use by default.

  • buttonLabel String (Optional)

    Custom label for the confirmation button. A default label will be used if empty.

  • filters Array Of Electron.FileFilter (Optional)
    Optionally filter files to open by.

  • message String (Optional)
    Message to display above text fields.

  • nameFieldLabel String (Optional)
    Custom label for the text displayed in front of the filename text field.

  • showsTagField Boolean (Optional)
    Show the tags input box, defaults to true.

  • showHiddenFiles Boolean (Optional)
    Show hidden files in dialog.

  • createDirectory Boolean macOS (Optional)
    Allow creating new directories from dialog.

  • treatPackageAsDirectory Boolean macOS (Optional)
    Treat packages, such as .app folders as a directory instead of a file.

  • dontAddToRecent Boolean Windows (Optional)
    Do not add the item being opened to the recent documents list.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • canceled Boolean
    Whether or not the dialog was canceled.
  • filePath String
    File path chosen by the user. If the dialog is cancelled this will be an empty string.

Example

const result = await window.deskifier.dialog.showSave();

console.log(result.filePath)
//["C:\\Users\\Example\\Path.jpg"]

Show Message Box

Shows a message box.

await window.deskifier.dialog.showMessageBox({ arguments })

Arguments

  • message String (Required)
    Content of the message box.

  • type String (Optional)

    Can be none, info, error, question or warning. On Windows, question displays the same icon as info.

  • buttons Array Of String (Optional)

    Array of texts for buttons. On Windows, an empty array will result in one button labeled "OK".

  • defaultId Number (Optional)
    Index of the button in the buttons array which will be selected by default when the message box opens.

  • title String (Optional)
    Title of the message box, some platforms will not show it.

  • detail String (Optional)
    Extra information of the message.

  • checkboxLabel String (Optional)
    If provided, the message box will include a checkbox with the given label.

  • checkboxChecked Boolean (Optional)
    Initial checked state of the checkbox. false by default.

  • cancelId Number (Optional)
    The index of the button to be used to cancel the dialog, via the Esc key. By default this is assigned to the first button with "cancel" or "no" as the label. If no such labeled buttons exist and this option is not set, 0 will be used as the return value.

  • noLink Boolean (Optional)
    On Windows Electron will try to figure out which one of the buttons are common buttons (like "Cancel" or "Yes"), and show the others as command links in the dialog. This can make the dialog appear in the style of modern Windows apps. If you don't like this behavior, you can set noLink to true.

  • normalizeAccessKeys Boolean (Optional)
    Normalize the keyboard access keys across platforms. Default is false. Enabling this assumes & is used in the button labels for the placement of the keyboard shortcut access key and labels will be converted so they work correctly on each platform, & characters are removed on macOS, converted to _ on Linux, and left untouched on Windows. For example, a button label of Vie&w will be converted to Vie_w on Linux and View on macOS and can be selected via Alt-W on Windows and Linux.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • response Number
    The index of the clicked button.
  • checkboxChecked Boolean
    The checked state of the checkbox if checkboxLabel was set. Otherwise false.

Show Error Box

Displays a modal dialog that shows an error message.

await window.deskifier.dialog.showError({ arguments })

Arguments

  • title String (Required)
    The title to display in the error box.

  • content String (Required)

    The text content to display in the error box.