Add noLink option for showMessageBox
This commit is contained in:
parent
1578d2fda9
commit
cc2a9f617d
4 changed files with 19 additions and 6 deletions
|
@ -11,6 +11,9 @@ fileDialogProperties =
|
||||||
|
|
||||||
messageBoxTypes = ['none', 'info', 'warning', 'error', 'question']
|
messageBoxTypes = ['none', 'info', 'warning', 'error', 'question']
|
||||||
|
|
||||||
|
messageBoxOptions =
|
||||||
|
noLink: 1 << 0
|
||||||
|
|
||||||
parseArgs = (window, options, callback) ->
|
parseArgs = (window, options, callback) ->
|
||||||
unless window is null or window?.constructor is BrowserWindow
|
unless window is null or window?.constructor is BrowserWindow
|
||||||
# Shift.
|
# Shift.
|
||||||
|
@ -101,10 +104,12 @@ module.exports =
|
||||||
options.cancelId = i
|
options.cancelId = i
|
||||||
break
|
break
|
||||||
|
|
||||||
|
flags = if options.noLink then messageBoxOptions.noLink else 0
|
||||||
|
|
||||||
binding.showMessageBox messageBoxType,
|
binding.showMessageBox messageBoxType,
|
||||||
options.buttons,
|
options.buttons,
|
||||||
options.cancelId,
|
options.cancelId,
|
||||||
0,
|
flags,
|
||||||
options.title,
|
options.title,
|
||||||
options.message,
|
options.message,
|
||||||
options.detail,
|
options.detail,
|
||||||
|
|
|
@ -28,8 +28,8 @@ enum MessageBoxType {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MessageBoxOptions {
|
enum MessageBoxOptions {
|
||||||
MESSAGE_BOX_NONE = 0,
|
MESSAGE_BOX_NONE = 0,
|
||||||
MESSAGE_BOX_NO_LINKS = 1 << 0,
|
MESSAGE_BOX_NO_LINK = 1 << 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef base::Callback<void(int code)> MessageBoxCallback;
|
typedef base::Callback<void(int code)> MessageBoxCallback;
|
||||||
|
|
|
@ -72,6 +72,7 @@ int ShowMessageBoxUTF16(HWND parent,
|
||||||
MessageBoxType type,
|
MessageBoxType type,
|
||||||
const std::vector<base::string16>& buttons,
|
const std::vector<base::string16>& buttons,
|
||||||
int cancel_id,
|
int cancel_id,
|
||||||
|
int options,
|
||||||
const base::string16& title,
|
const base::string16& title,
|
||||||
const base::string16& message,
|
const base::string16& message,
|
||||||
const base::string16& detail,
|
const base::string16& detail,
|
||||||
|
@ -126,7 +127,8 @@ int ShowMessageBoxUTF16(HWND parent,
|
||||||
if (dialog_buttons.size() > 0) {
|
if (dialog_buttons.size() > 0) {
|
||||||
config.pButtons = &dialog_buttons.front();
|
config.pButtons = &dialog_buttons.front();
|
||||||
config.cButtons = dialog_buttons.size();
|
config.cButtons = dialog_buttons.size();
|
||||||
config.dwFlags |= TDF_USE_COMMAND_LINKS; // custom buttons as links.
|
if (!(options & MESSAGE_BOX_NO_LINK))
|
||||||
|
config.dwFlags |= TDF_USE_COMMAND_LINKS; // custom buttons as links.
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
@ -181,6 +183,7 @@ int ShowMessageBox(NativeWindow* parent,
|
||||||
type,
|
type,
|
||||||
utf16_buttons,
|
utf16_buttons,
|
||||||
cancel_id,
|
cancel_id,
|
||||||
|
options,
|
||||||
base::UTF8ToUTF16(title),
|
base::UTF8ToUTF16(title),
|
||||||
base::UTF8ToUTF16(message),
|
base::UTF8ToUTF16(message),
|
||||||
base::UTF8ToUTF16(detail),
|
base::UTF8ToUTF16(detail),
|
||||||
|
@ -214,7 +217,7 @@ void ShowMessageBox(NativeWindow* parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowErrorBox(const base::string16& title, const base::string16& content) {
|
void ShowErrorBox(const base::string16& title, const base::string16& content) {
|
||||||
ShowMessageBoxUTF16(NULL, MESSAGE_BOX_TYPE_ERROR, {}, 0, L"Error", title,
|
ShowMessageBoxUTF16(NULL, MESSAGE_BOX_TYPE_ERROR, {}, 0, 0, L"Error", title,
|
||||||
content, gfx::ImageSkia());
|
content, gfx::ImageSkia());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,12 @@ will be passed via `callback(filename)`
|
||||||
instead of clicking the buttons of the dialog. By default it is the index
|
instead of clicking the buttons of the dialog. By default it is the index
|
||||||
of the buttons that have "cancel" or "no" as label, or 0 if there is no such
|
of the buttons that have "cancel" or "no" as label, or 0 if there is no such
|
||||||
buttons. On OS X and Windows the index of "Cancel" button will always be
|
buttons. On OS X and Windows the index of "Cancel" button will always be
|
||||||
used as `cancelId`, not matter whether it is already specified.
|
used as `cancelId`, not matter whether it is already specified
|
||||||
|
* `noLink` Boolean - On Windows Electron would try to figure out which ones 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
|
||||||
|
specify `noLink` to `true`
|
||||||
* `callback` Function
|
* `callback` Function
|
||||||
|
|
||||||
Shows a message box, it will block until the message box is closed. It returns
|
Shows a message box, it will block until the message box is closed. It returns
|
||||||
|
|
Loading…
Reference in a new issue