From 6c0535db4529e9a68a5b13a5ba01d4758c4b3729 Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Thu, 1 Sep 2011 22:01:54 +0200 Subject: [PATCH] Fixed OSX/ShowMouseCursor --- src/SFML/Window/OSX/WindowImplCocoa.hpp | 3 ++- src/SFML/Window/OSX/WindowImplCocoa.mm | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/SFML/Window/OSX/WindowImplCocoa.hpp b/src/SFML/Window/OSX/WindowImplCocoa.hpp index cadf97c2..7c389515 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.hpp +++ b/src/SFML/Window/OSX/WindowImplCocoa.hpp @@ -311,7 +311,8 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - WindowImplDelegateRef myDelegate; ///< Implementation in Obj-C. + WindowImplDelegateRef myDelegate; ///< Implementation in Obj-C. + bool myShowCursor; ///< Is the cursor displayed or hidden ? }; } // namespace priv diff --git a/src/SFML/Window/OSX/WindowImplCocoa.mm b/src/SFML/Window/OSX/WindowImplCocoa.mm index 84c4ae82..7697e2eb 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.mm +++ b/src/SFML/Window/OSX/WindowImplCocoa.mm @@ -44,6 +44,7 @@ namespace priv //////////////////////////////////////////////////////////// WindowImplCocoa::WindowImplCocoa(WindowHandle handle) +: myShowCursor(true) { // Ask for a pool. RetainPool(); @@ -91,6 +92,7 @@ WindowImplCocoa::WindowImplCocoa(WindowHandle handle) WindowImplCocoa::WindowImplCocoa(VideoMode mode, const std::string& title, unsigned long style) +: myShowCursor(true) { // Transform the app process. SetUpProcess(); @@ -183,6 +185,10 @@ void WindowImplCocoa::WindowResized(unsigned int width, unsigned int height) //////////////////////////////////////////////////////////// void WindowImplCocoa::WindowLostFocus(void) { + if (!myShowCursor) { + [myDelegate showMouseCursor]; // Make sur the cursor is visible + } + Event event; event.Type = Event::LostFocus; @@ -193,6 +199,10 @@ void WindowImplCocoa::WindowLostFocus(void) //////////////////////////////////////////////////////////// void WindowImplCocoa::WindowGainedFocus(void) { + if (!myShowCursor) { + [myDelegate hideMouseCursor]; // Restore user's setting + } + Event event; event.Type = Event::GainedFocus; @@ -255,6 +265,10 @@ void WindowImplCocoa::MouseWheelScrolledAt(float delta, int x, int y) //////////////////////////////////////////////////////////// void WindowImplCocoa::MouseMovedIn(void) { + if (!myShowCursor) { + [myDelegate hideMouseCursor]; // Restore user's setting + } + Event event; event.Type = Event::MouseEntered; @@ -264,6 +278,10 @@ void WindowImplCocoa::MouseMovedIn(void) //////////////////////////////////////////////////////////// void WindowImplCocoa::MouseMovedOut(void) { + if (!myShowCursor) { + [myDelegate showMouseCursor]; // Make sur the cursor is visible + } + Event event; event.Type = Event::MouseLeft; @@ -330,7 +348,9 @@ WindowHandle WindowImplCocoa::GetSystemHandle() const //////////////////////////////////////////////////////////// void WindowImplCocoa::ShowMouseCursor(bool show) { - if (show) { + myShowCursor = show; + + if (myShowCursor) { [myDelegate showMouseCursor]; } else { [myDelegate hideMouseCursor];