summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2016-06-23 07:39:34 +0200
committerGitHub <noreply@github.com>2016-06-23 07:39:34 +0200
commit92ee868a94cdd55bbadc39e0e28447d08e7aa0ee (patch)
treecc8ec507155e5b15e5b951c8382e4d036593c54e
parent3cafcaedd02133a5a22708cafe62e951fca8b803 (diff)
parent072da51f20870ec2949ed306be46501905b93a75 (diff)
Merge pull request #5358 from Keyaku/alert-for-osx
Added alert() functionality for OS X
-rw-r--r--platform/osx/os_osx.h2
-rw-r--r--platform/osx/os_osx.mm16
2 files changed, 18 insertions, 0 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 8d64686335..e1c33cb018 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -142,6 +142,8 @@ public:
virtual String get_name();
+ virtual void alert(const String& p_alert, const String& p_title="ALERT!");
+
virtual void set_cursor_shape(CursorShape p_shape);
virtual void set_mouse_show(bool p_show);
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index b5503fcd73..45c500ec39 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1209,6 +1209,22 @@ String OS_OSX::get_name() {
return "OSX";
}
+void OS_OSX::alert(const String& p_alert, const String& p_title) {
+ // Set OS X-compliant variables
+ NSAlert *window = [[NSAlert alloc] init];
+ NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()];
+ NSString *ns_alert = [NSString stringWithUTF8String:p_alert.utf8().get_data()];
+
+ [window addButtonWithTitle:@"OK"];
+ [window setMessageText:ns_title];
+ [window setInformativeText:ns_alert];
+ [window setAlertStyle:NSWarningAlertStyle];
+
+ // Display it, then release
+ [window runModal];
+ [window release];
+}
+
void OS_OSX::set_cursor_shape(CursorShape p_shape) {
if (cursor_shape==p_shape)