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
titleString (Optional)
A title for the dialog box.defaultPathString (Optional)Which directory the file explorer will open on.
buttonLabelString (Optional)Custom label for the confirmation button. A default label will be used if empty.
filtersArray Of Electron.FileFilter (Optional)
Optionally filter files to open by.openFileBoolean (Optional)
Allows files to be selected.openDirectoryBoolean (Optional)
Allow directories to be selected.multiSelectionsBoolean (Optional)
Allow multiple paths to be selected.showHiddenFilesBoolean (Optional)
Show hidden files in dialog.createDirectoryBoolean macOS (Optional)
Allow creating new directories from dialog.promptToCreateBoolean 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.treatPackageAsDirectoryBoolean macOS (Optional)
Treat packages, such as .app folders as a directory instead of a file.dontAddToRecentBoolean Windows (Optional)
Do not add the item being opened to the recent documents list.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.canceledBoolean
Whether or not the dialog was canceled.filePathsArray 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
titleString (Optional)
A title for the dialog box.defaultPathString (Optional)Absolute directory path, absolute file path, or file name to use by default.
buttonLabelString (Optional)Custom label for the confirmation button. A default label will be used if empty.
filtersArray Of Electron.FileFilter (Optional)
Optionally filter files to open by.messageString (Optional)
Message to display above text fields.nameFieldLabelString (Optional)
Custom label for the text displayed in front of the filename text field.showsTagFieldBoolean (Optional)
Show the tags input box, defaults to true.showHiddenFilesBoolean (Optional)
Show hidden files in dialog.createDirectoryBoolean macOS (Optional)
Allow creating new directories from dialog.treatPackageAsDirectoryBoolean macOS (Optional)
Treat packages, such as .app folders as a directory instead of a file.dontAddToRecentBoolean Windows (Optional)
Do not add the item being opened to the recent documents list.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.canceledBoolean
Whether or not the dialog was canceled.filePathString
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
messageString (Required)
Content of the message box.typeString (Optional)Can be
none,info,error,questionorwarning. On Windows, question displays the same icon asinfo.buttonsArray Of String (Optional)Array of texts for buttons. On Windows, an empty array will result in one button labeled "OK".
defaultIdNumber (Optional)
Index of the button in the buttons array which will be selected by default when the message box opens.titleString (Optional)
Title of the message box, some platforms will not show it.detailString (Optional)
Extra information of the message.checkboxLabelString (Optional)
If provided, the message box will include a checkbox with the given label.checkboxCheckedBoolean (Optional)
Initial checked state of the checkbox.falseby default.cancelIdNumber (Optional)
The index of the button to be used to cancel the dialog, via theEsckey. 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,0will be used as the return value.noLinkBoolean (Optional)
On Windows Electron will try to figure out which one of thebuttonsare 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 setnoLinktotrue.normalizeAccessKeysBoolean (Optional)
Normalize the keyboard access keys across platforms. Default isfalse. 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 ofVie&wwill be converted toVie_won Linux andViewon macOS and can be selected viaAlt-Won Windows and Linux.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.responseNumber
The index of the clicked button.checkboxCheckedBoolean
The checked state of the checkbox ifcheckboxLabelwas set. Otherwisefalse.
Show Error Box
Displays a modal dialog that shows an error message.
await window.deskifier.dialog.showError({ arguments })
Arguments
titleString (Required)
The title to display in the error box.contentString (Required)The text content to display in the error box.