dialog
System dialog functionality, including opening, saving files, prompts, alerts, etc.
Below is an example of a dialog box for selecting multiple files:
Methods
showOpenDialog(options)
Displays the open file dialog.
options
Objecttitle
string (optional) - The title of the dialog windowdefaultPath
string (optional) - The default display path of the dialogbuttonLabel
string (optional) - Custom label for the "Confirm" button; if empty, the default label is used.filters
FileFilter[] (optional)name
stringextensions
string[]
properties
string[] (optional) - Contains dialog-related attributes. The following attribute values are supported:openFile
- Allows selecting filesopenDirectory
- Allows selecting foldersmultiSelections
- Allows multiple selections.showHiddenFiles
- Displays hidden files in the dialog.createDirectory
macOS
- Allows you to create a new directory through the dialog.promptToCreate
Windows
- If the entered file path does not exist in the dialog, prompt to create it. This does not actually create a file on the path but allows returning some non-existent addresses for the application to create.
message
string (optional)macOS
- The message displayed above the input box.
Returns
Promise<result: Object>
result
Objectcanceled
boolean - Whether the dialog was canceledfilePaths
string[] - Array of chosen file paths by the user. If the dialog is canceled, this will be an empty array.
Note: This feature is similar to Electron API's dialog.showOpenDialog feature.
showSaveDialog(options)
Displays the save file dialog.
options
Objecttitle
string (optional) - The title of the dialog windowdefaultPath
string (optional) - The default display path of the dialogbuttonLabel
string (optional) - Custom label for the "Confirm" button; if empty, the default label is used.filters
FileFilter[] (optional)name
stringextensions
string[]
properties
string[] (optional) - Contains dialog-related attributes. The following attribute values are supported:openDirectory
- Allows selecting foldersshowHiddenFiles
- Displays hidden files in the dialog.createDirectory
macOS
- Allows you to create a new directory through the dialog.
Returns
Promise<result: Object>
result
Objectcanceled
boolean - Whether the dialog was canceledfilePath
string - If the dialog is canceled, this value will beundefined
.
Note: This function is similar to the Electron API's dialog.showSaveDialog function.
showMessageBox(options)
Display a message dialog.
options
Objectmessage
string - The main content of the dialogtitle
string (optional) - Dialog titledetail
string (optional) - Additional informationbuttons
strings[] (optional) - Array of button textstype
string (optional) - Can benone
,info
,error
,question
, orwarning
Returns
Promise<result: Object>
result
Objectresponse
Integer - The index of the clicked button
This function is similar to the Electron API's dialog.showSaveDialog function.
showErrorBox(title, content)
Display an error message dialog.
title
string - The title displayed in the error boxcontent
string - The text content displayed in the error boxReturns
Promise<void>
Note: This function is similar to the Electron API's dialog.showSaveDialog function.
Last updated