From dc55068db1752978db1140a02a39565905fc500f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 23 Dec 2011 16:57:34 +0000 Subject: [PATCH] From James Turner, "Testing FlightGear with Cocoa osgViewer, encountered some problems with hiding / re-showing the cursor. Attached version fixes this, by tracking the current cursor value, and ensuring we don't nest calls to [NSCursor hide] or [NSCursor unhide]." --- src/osgViewer/GraphicsWindowCocoa.mm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/osgViewer/GraphicsWindowCocoa.mm b/src/osgViewer/GraphicsWindowCocoa.mm index d3854a71c..73cf980ca 100644 --- a/src/osgViewer/GraphicsWindowCocoa.mm +++ b/src/osgViewer/GraphicsWindowCocoa.mm @@ -1357,8 +1357,11 @@ void GraphicsWindowCocoa::useCursor(bool cursorOn) void GraphicsWindowCocoa::setCursor(MouseCursor mouseCursor) { - NSAutoreleasePool* localPool = [[NSAutoreleasePool alloc] init]; + if (_currentCursor == mouseCursor) { + return; + } + NSAutoreleasePool* localPool = [[NSAutoreleasePool alloc] init]; switch (mouseCursor) { @@ -1367,6 +1370,7 @@ void GraphicsWindowCocoa::setCursor(MouseCursor mouseCursor) break; case LeftArrowCursor: + case RightArrowCursor: [[NSCursor arrowCursor] set]; break; @@ -1379,9 +1383,14 @@ void GraphicsWindowCocoa::setCursor(MouseCursor mouseCursor) break; default: - OSG_INFO << "GraphicsWindowCocoa::setCursor :: unsupported MouseCursor: " << mouseCursor << std::endl; + OSG_INFO << "GraphicsWindowCocoa::setCursor :: unsupported MouseCursor: " << mouseCursor << std::endl; } + if (_currentCursor == NoCursor) { + [NSCursor unhide]; + } + + _currentCursor = mouseCursor; [localPool release]; }