!args[4]->IsString()) // detail
return node::ThrowTypeError("Bad argument");
+ NativeWindow* native_window = NULL;
+ if (args[5]->IsObject()) {
+ Window* window = Window::Unwrap<Window>(args[5]->ToObject());
+ if (!window || !window->window())
+ return node::ThrowError("Invalid window");
+
+ native_window = window->window();
+ }
+
MessageBoxType type = (MessageBoxType)(args[0]->IntegerValue());
std::vector<std::string> buttons;
std::string message(*v8::String::Utf8Value(args[3]));
std::string detail(*v8::String::Utf8Value(args[4]));
- int chosen = atom::ShowMessageBox(type, buttons, title, message, detail);
+ int chosen = atom::ShowMessageBox(
+ native_window, type, buttons, title, message, detail);
return scope.Close(v8::Integer::New(chosen));
}
binding.showSaveDialog window, options.title, options.defaultPath
- showMessageBox: (options) ->
+ showMessageBox: (window, options) ->
+ if window?.constructor isnt BrowserWindow
+ options = window
+ window = null
+
options = type: 'none' unless options?
options.type = options.type ? 'none'
options.type = messageBoxTypes.indexOf options.type
options.message = options.message ? ''
options.detail = options.detail ? ''
- binding.showMessageBox options.type, options.buttons,
+ binding.showMessageBox options.type,
+ options.buttons,
String(options.title),
String(options.message),
- String(options.detail)
+ String(options.detail),
+ window
namespace atom {
+class NativeWindow;
+
enum MessageBoxType {
MESSAGE_BOX_TYPE_NONE = 0,
MESSAGE_BOX_TYPE_INFORMATION,
MESSAGE_BOX_TYPE_WARNING
};
-int ShowMessageBox(MessageBoxType type,
+int ShowMessageBox(NativeWindow* parent_window,
+ MessageBoxType type,
const std::vector<std::string>& buttons,
const std::string& title,
const std::string& message,
#import <Cocoa/Cocoa.h>
#include "base/strings/sys_string_conversions.h"
+#include "browser/native_window.h"
+#include "browser/nsalert_synchronous_sheet.h"
namespace atom {
-int ShowMessageBox(MessageBoxType type,
+int ShowMessageBox(NativeWindow* parent_window,
+ MessageBoxType type,
const std::vector<std::string>& buttons,
const std::string& title,
const std::string& message,
[button setTag:i];
}
- return [alert runModal];
+ if (parent_window)
+ return [alert runModalSheetForWindow:parent_window->GetNativeWindow()];
+ else
+ return [alert runModal];
}
} // namespace atom