summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/osx/os_osx.h4
-rw-r--r--platform/osx/os_osx.mm26
2 files changed, 29 insertions, 1 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index b9e381d6ec..5b203f1560 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -98,7 +98,7 @@ public:
id context;
CursorShape cursor_shape;
-
+ MouseMode mouse_mode;
protected:
virtual int get_video_driver_count() const;
@@ -159,6 +159,8 @@ public:
void run();
+ void set_mouse_mode(MouseMode p_mode);
+ MouseMode get_mouse_mode() const;
OS_OSX();
};
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index dda3527618..c09a45bbad 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1280,6 +1280,32 @@ void OS_OSX::run() {
main_loop->finish();
}
+void OS_OSX::set_mouse_mode(MouseMode p_mode) {
+
+ if (p_mode==mouse_mode)
+ return;
+
+ if (p_mode==MOUSE_MODE_CAPTURED) {
+ // Apple Docs state that the display parameter is not used.
+ // "This parameter is not used. By default, you may pass kCGDirectMainDisplay."
+ // https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/Quartz_Services_Ref/Reference/reference.html
+ CGDisplayHideCursor(kCGDirectMainDisplay);
+ CGAssociateMouseAndMouseCursorPosition(false);
+ } else if (p_mode==MOUSE_MODE_HIDDEN) {
+ CGDisplayHideCursor(kCGDirectMainDisplay);
+ CGAssociateMouseAndMouseCursorPosition(true);
+ } else {
+ CGDisplayShowCursor(kCGDirectMainDisplay);
+ CGAssociateMouseAndMouseCursorPosition(true);
+ }
+
+ mouse_mode=p_mode;
+}
+
+OS::MouseMode OS_OSX::get_mouse_mode() const {
+
+ return mouse_mode;
+}
OS_OSX* OS_OSX::singleton=NULL;