mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 03:18:37 +08:00
Merge pull request #548 from Felbo/master
mouse_mode implementation on OS X.
This commit is contained in:
commit
1cc96a4d74
@ -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();
|
||||
};
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user