dialog
System dialog functionality, including opening, saving files, prompts, alerts, etc.
Below is an example of a dialog box for selecting multiple files:
let result = await eagle.dialog.showOpenDialog({
properties: ['openFile', 'multiSelections']
});Methods
showOpenDialog(options)
Displays the open file dialog.
optionsObjecttitlestring (optional) - The title of the dialog windowdefaultPathstring (optional) - The default display path of the dialogbuttonLabelstring (optional) - Custom label for the "Confirm" button; if empty, the default label is used.filtersFileFilter[] (optional)namestringextensionsstring[]
propertiesstring[] (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.createDirectorymacOS- Allows you to create a new directory through the dialog.promptToCreateWindows- 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.
messagestring (optional)macOS- The message displayed above the input box.
Returns
Promise<result: Object>resultObjectcanceledboolean - Whether the dialog was canceledfilePathsstring[] - Array of chosen file paths by the user. If the dialog is canceled, this will be an empty array.
{
filters: [
{ name: 'Images', extensions: ['jpg', 'png', 'gif'] },
{ name: 'Movies', extensions: ['mkv', 'avi', 'mp4'] },
{ name: 'Custom File Type', extensions: ['as'] },
{ name: 'All Files', extensions: ['*'] }
]
}let result = await eagle.dialog.showOpenDialog({
properties: ['openFile', 'openDirectory']
});showSaveDialog(options)
Displays the save file dialog.
optionsObjecttitlestring (optional) - The title of the dialog windowdefaultPathstring (optional) - The default display path of the dialogbuttonLabelstring (optional) - Custom label for the "Confirm" button; if empty, the default label is used.filtersFileFilter[] (optional)namestringextensionsstring[]
propertiesstring[] (optional) - Contains dialog-related attributes. The following attribute values are supported:openDirectory- Allows selecting foldersshowHiddenFiles- Displays hidden files in the dialog.createDirectorymacOS- Allows you to create a new directory through the dialog.
Returns
Promise<result: Object>resultObjectcanceledboolean - Whether the dialog was canceledfilePathstring - If the dialog is canceled, this value will beundefined.
{
filters: [
{ name: 'Images', extensions: ['jpg', 'png', 'gif'] },
{ name: 'Movies', extensions: ['mkv', 'avi', 'mp4'] },
{ name: 'Custom File Type', extensions: ['as'] },
{ name: 'All Files', extensions: ['*'] }
]
}let result = await eagle.dialog.showSaveDialog({
properties: ['openDirectory']
});showMessageBox(options)
Display a message dialog.
optionsObjectmessagestring - The main content of the dialogtitlestring (optional) - Dialog titledetailstring (optional) - Additional informationbuttonsstrings[] (optional) - Array of button textstypestring (optional) - Can benone,info,error,question, orwarning
Returns
Promise<result: Object>resultObjectresponseInteger - The index of the clicked button
let result = await eagle.dialog.showMessageBox({
title: "Messagebox title",
message: "Message from the Plugin process",
detail: "Ultra message here",
buttons: ["OK", "Cancel"],
type: "info"
});
console.log(result); // {response: 0}showErrorBox(title, content)
Display an error message dialog.
titlestring - The title displayed in the error boxcontentstring - The text content displayed in the error boxReturns
Promise<void>
await eagle.dialog.showErrorBox("Error box title", "Error message from the Plugin process");Last updated