Merge pull request #8566 from electron/prompt-to-create-property
Support returning non-existent file paths from Windows open dialog
This commit is contained in:
commit
62a400b7d6
4 changed files with 16 additions and 4 deletions
|
@ -28,6 +28,7 @@ enum FileDialogProperty {
|
||||||
FILE_DIALOG_MULTI_SELECTIONS = 1 << 2,
|
FILE_DIALOG_MULTI_SELECTIONS = 1 << 2,
|
||||||
FILE_DIALOG_CREATE_DIRECTORY = 1 << 3,
|
FILE_DIALOG_CREATE_DIRECTORY = 1 << 3,
|
||||||
FILE_DIALOG_SHOW_HIDDEN_FILES = 1 << 4,
|
FILE_DIALOG_SHOW_HIDDEN_FILES = 1 << 4,
|
||||||
|
FILE_DIALOG_PROMPT_TO_CREATE = 1 << 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef base::Callback<void(
|
typedef base::Callback<void(
|
||||||
|
|
|
@ -205,6 +205,8 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||||
options |= FOS_ALLOWMULTISELECT;
|
options |= FOS_ALLOWMULTISELECT;
|
||||||
if (properties & FILE_DIALOG_SHOW_HIDDEN_FILES)
|
if (properties & FILE_DIALOG_SHOW_HIDDEN_FILES)
|
||||||
options |= FOS_FORCESHOWHIDDEN;
|
options |= FOS_FORCESHOWHIDDEN;
|
||||||
|
if (properties & FILE_DIALOG_PROMPT_TO_CREATE)
|
||||||
|
options |= FOS_CREATEPROMPT;
|
||||||
|
|
||||||
FileDialog<CShellFileOpenDialog> open_dialog(
|
FileDialog<CShellFileOpenDialog> open_dialog(
|
||||||
default_path, title, button_label, filters, options);
|
default_path, title, button_label, filters, options);
|
||||||
|
|
|
@ -32,9 +32,17 @@ The `dialog` module has the following methods:
|
||||||
* `buttonLabel` String (optional) - Custom label for the confirmation button, when
|
* `buttonLabel` String (optional) - Custom label for the confirmation button, when
|
||||||
left empty the default label will be used.
|
left empty the default label will be used.
|
||||||
* `filters` [FileFilter[]](structures/file-filter.md) (optional)
|
* `filters` [FileFilter[]](structures/file-filter.md) (optional)
|
||||||
* `properties` String[] (optional) - Contains which features the dialog should use, can
|
* `properties` String[] (optional) - Contains which features the dialog should
|
||||||
contain `openFile`, `openDirectory`, `multiSelections`, `createDirectory`
|
use. The following values are supported:
|
||||||
and `showHiddenFiles`.
|
* `openFile` - Allow files to be selected.
|
||||||
|
* `openDirectory` - Allow directories to be selected.
|
||||||
|
* `multiSelections` - Allow multiple paths to be selected.
|
||||||
|
* `showHiddenFiles` - Show hidden files in dialog.
|
||||||
|
* `createDirectory` _macOS_ - Allow creating new directories from dialog.
|
||||||
|
* `promptToCreate` _Windows_ - 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.
|
||||||
* `normalizeAccessKeys` Boolean (optional) - Normalize the keyboard access keys
|
* `normalizeAccessKeys` Boolean (optional) - Normalize the keyboard access keys
|
||||||
across platforms. Default is `false`. Enabling this assumes `&` is used in
|
across platforms. Default is `false`. Enabling this assumes `&` is used in
|
||||||
the button labels for the placement of the keyboard shortcut access key
|
the button labels for the placement of the keyboard shortcut access key
|
||||||
|
|
|
@ -9,7 +9,8 @@ const fileDialogProperties = {
|
||||||
openDirectory: 1 << 1,
|
openDirectory: 1 << 1,
|
||||||
multiSelections: 1 << 2,
|
multiSelections: 1 << 2,
|
||||||
createDirectory: 1 << 3,
|
createDirectory: 1 << 3,
|
||||||
showHiddenFiles: 1 << 4
|
showHiddenFiles: 1 << 4,
|
||||||
|
promptToCreate: 1 << 5
|
||||||
}
|
}
|
||||||
|
|
||||||
const messageBoxTypes = ['none', 'info', 'warning', 'error', 'question']
|
const messageBoxTypes = ['none', 'info', 'warning', 'error', 'question']
|
||||||
|
|
Loading…
Reference in a new issue