diff --git a/atom/browser/api/lib/dialog.coffee b/atom/browser/api/lib/dialog.coffee index a1dcaafe78fe..0843af04282e 100644 --- a/atom/browser/api/lib/dialog.coffee +++ b/atom/browser/api/lib/dialog.coffee @@ -11,6 +11,9 @@ fileDialogProperties = messageBoxTypes = ['none', 'info', 'warning', 'error', 'question'] +messageBoxOptions = + noLink: 1 << 0 + parseArgs = (window, options, callback) -> unless window is null or window?.constructor is BrowserWindow # Shift. @@ -101,10 +104,12 @@ module.exports = options.cancelId = i break + flags = if options.noLink then messageBoxOptions.noLink else 0 + binding.showMessageBox messageBoxType, options.buttons, options.cancelId, - 0, + flags, options.title, options.message, options.detail, diff --git a/atom/browser/ui/message_box.h b/atom/browser/ui/message_box.h index 22cfa267b256..92052d3de4a4 100644 --- a/atom/browser/ui/message_box.h +++ b/atom/browser/ui/message_box.h @@ -28,8 +28,8 @@ enum MessageBoxType { }; enum MessageBoxOptions { - MESSAGE_BOX_NONE = 0, - MESSAGE_BOX_NO_LINKS = 1 << 0, + MESSAGE_BOX_NONE = 0, + MESSAGE_BOX_NO_LINK = 1 << 0, }; typedef base::Callback MessageBoxCallback; diff --git a/atom/browser/ui/message_box_win.cc b/atom/browser/ui/message_box_win.cc index d8e088072306..194a0d79f8f8 100644 --- a/atom/browser/ui/message_box_win.cc +++ b/atom/browser/ui/message_box_win.cc @@ -72,6 +72,7 @@ int ShowMessageBoxUTF16(HWND parent, MessageBoxType type, const std::vector& buttons, int cancel_id, + int options, const base::string16& title, const base::string16& message, const base::string16& detail, @@ -126,7 +127,8 @@ int ShowMessageBoxUTF16(HWND parent, if (dialog_buttons.size() > 0) { config.pButtons = &dialog_buttons.front(); 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; @@ -181,6 +183,7 @@ int ShowMessageBox(NativeWindow* parent, type, utf16_buttons, cancel_id, + options, base::UTF8ToUTF16(title), base::UTF8ToUTF16(message), base::UTF8ToUTF16(detail), @@ -214,7 +217,7 @@ void ShowMessageBox(NativeWindow* parent, } 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()); } diff --git a/docs/api/dialog.md b/docs/api/dialog.md index f6b65a1bb06c..d9336c0c8a3a 100644 --- a/docs/api/dialog.md +++ b/docs/api/dialog.md @@ -80,7 +80,12 @@ will be passed via `callback(filename)` 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 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 Shows a message box, it will block until the message box is closed. It returns