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]."

This commit is contained in:
Robert Osfield
2011-12-23 16:57:34 +00:00
parent fa2e8b22c5
commit dc55068db1

View File

@@ -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];
}