PDA

View Full Version : NSView fullscreen




hoschi
Nov 14, 2005, 09:53 AM
Hi:

I have a program running which uses fullscreen mode also- that is I can go full screen as well. I have a custom view in this window (where I show some opengl stuff) and some buttons/controls..

The problem is this..
Once I go to the fullscreen and come back, my normal sized window cannot display the custom view but only displays the normal window with controls and without the custom view itself..

I read somewhere that in order for any other views to be shown, they should be made subviews of the content view. I have no clue how to do that.

Also if anyone thinks there is another way around this, it could be helpful...
Below is the relevant part of the code...

---------

-(IBAction)fullScreen:(id)sender
{
if (fullScreenMode)
{
[fullScreenWindow close];
[startingWindow setAcceptsMouseMovedEvents:YES];
// [startingWindow setContentView:];
[startingWindow makeKeyAndOrderFront:nil];
// [startingWindow makeFirstResponder:myGLView];
fullScreenMode = NO;
} else
{
unsigned int windowStyle;
NSRect contentRect;
startingWindow = [NSApp keyWindow];
windowStyle = NSBorderlessWindowMask;
contentRect = [[NSScreen mainScreen] frame];
fullScreenWindow = [[NSWindow alloc] initWithContentRect:contentRect
styleMask:windowStyle
backing:NSBackingStoreBuffered
defer:NO];
[startingWindow setAcceptsMouseMovedEvents:NO];

if(fullScreenWindow != nil)
{
[fullScreenWindow setTitle:@"GL Viewer"];
[fullScreenWindow setReleasedWhenClosed:YES];
[fullScreenWindow setAcceptsMouseMovedEvents:YES];
[fullScreenWindow setContentView:myGLView];
[fullScreenWindow makeKeyAndOrderFront:myGLView];
[fullScreenWindow setLevel:NSScreenSaverWindowLevel -1];
[fullScreenWindow makeFirstResponder:myGLView];
fullScreenMode = YES;
}
}
}



robbieduncan
Nov 14, 2005, 10:09 AM
...I read somewhere that in order for any other views to be shown, they should be made subviews of the content view. I have no clue how to do that.


This is easy:

NSWindow *window = <code to get window>;
NSView *view = <code to get view>;

[[window contentView] addSubview:view];
<set view frame etc>


p.s. if you wrap you code in CODE tags it's a bit easier to read :)

HiRez
Nov 14, 2005, 10:11 AM
I read somewhere that in order for any other views to be shown, they should be made subviews of the content view. I have no clue how to do that.Just use[[myWindow contentView] addSubview:mySubview]

robbieduncan
Nov 14, 2005, 10:13 AM
Just use[[myWindow contentView] addSubView:mySubView]

Beat you to it :p

And it's addSubview: (I just checked to make sure)

HiRez
Nov 14, 2005, 10:13 AM
Beat you to it :p

And it's addSubview: (I just checked to make sure)
Heh, I just changed that too!

hoschi
Nov 14, 2005, 11:03 AM
Heh, I just changed that too!
I added the line and added [[myWindow contentView] addSubview:myView]

HoweverI am getting the same problem as before

robbieduncan
Nov 14, 2005, 11:24 AM
Can you host the XCode project somewhere (as a zip or something). The code above is a bit difficult to understand on it's own...

HiRez
Nov 14, 2005, 06:06 PM
I added the line and added [[myWindow contentView] addSubview:myView]

HoweverI am getting the same problem as before
Sorry, in the Mac world, when you see "my<Something>" if usually means "substitute the actual name of the object I'm using here". So in your case it sounds like it would be:[[fullScreenWindow contentView] addSubview:myGLView];Whether that actually works to accomplish what you're going for, I don't know, I'm just going off what you said about adding subviews to a content view.

EDIT: fixed typo...again! :P