From Eric Wing, "For osgviewerCocoa, a very simple change to allow toggling between

fullscreen mode and back between views. (To activate, double click on
the view to toggle.) It demonstrates/uses the new one-liner fullscreen
method introduced in Leopard. Code will still compile and run in
pre-Leopard (thanks to Obj-C dynamic/late binding), but code path is
treated as a no-op in those cases."
This commit is contained in:
Robert Osfield 2007-12-10 20:36:34 +00:00
parent aa24c273c7
commit b668a54e17
2 changed files with 27 additions and 0 deletions

View File

@ -186,6 +186,7 @@ namespace osgViewer
// Examples of providing an action to connect to.
- (IBAction) resetPosition:(id)the_sender;
- (IBAction) takeBackgroundColorFrom:(id)the_sender;
- (IBAction) toggleFullScreen:(id)the_sender;
@end

View File

@ -674,6 +674,11 @@ A -respondsToSelector: check has been used to provide compatibility with previou
else
{
theViewer->getEventQueue()->mouseDoubleButtonPress(converted_point.x, converted_point.y, 1);
// Let's toggle fullscreen for show
[self toggleFullScreen:nil];
}
[self setNeedsDisplay:YES];
}
@ -1388,6 +1393,27 @@ A -respondsToSelector: check has been used to provide compatibility with previou
[self setNeedsDisplay:YES];
}
- (IBAction) toggleFullScreen:(id)the_sender
{
// I'm lazy and rather use the new 10.5 Cocoa Fullscreen API.
// For now, no legacy support for fullscreen.
// One of the cool things about Obj-C is dynamic/late binding.
// We can compile and run this code on versions prior to 10.5.
// At run-time, we check to see if these methods actually exist
// and if they do, we message them. If not, we avoid them.
if([self respondsToSelector:@selector(isInFullScreenMode)])
{
if([self isInFullScreenMode])
{
[self exitFullScreenModeWithOptions:nil];
}
else
{
[self enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];
}
}
}
////////////////////////////////////////////////////////////////////////
/////////////////////////// End IBAction examples /////////////////////
////////////////////////////////////////////////////////////////////////