Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
i have a custom view object called "windowColor" in my NIB... i'm trying to make the main window include the custom view for display when the window opens, but i can't get it to work. i've created an outlet in the mainWindow and connected it to the custom view object...the window starts up fine, but the custom view is not being displayed within the window... any help would be great:

Code:
#import <Cocoa/Cocoa.h>
#import "windowColor.h"

@interface mainWindow : NSWindow {
	IBOutlet windowColor *fullscreenView;
}

@end

-------

#import "mainWindow.h"
#import <Carbon/Carbon.h>

@implementation mainWindow

- (id) initWithContentRect: (NSRect) contentRect
                 styleMask: (unsigned int) aStyle
                   backing: (NSBackingStoreType) bufferingType
                     defer: (BOOL) flag
	{
    if (self = [super initWithContentRect: contentRect
							styleMask: NSBorderlessWindowMask
                              backing: bufferingType
                                defer: flag])
	{
	SetSystemUIMode(kUIModeAllHidden, 0);
	[self setFrame:[[NSScreen mainScreen] visibleFrame] display:YES animate:NO];
	[self setContentView:fullscreenView];
	SetSystemUIMode(kUIModeAllSuppressed, 0);
	}
    return self;
}


@end
 

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
ok... i was able to get it to start working by adding this to the mainWindow.m:

Code:
- (void)awakeFromNib {
		[self setContentView:fullscreenView];
}

however, is there anyway to add the setContentView code to the init? or does it not matter? i'm asking because i'm creating 2 windows (one for normal view, one for full screen view)... i'm just concerned that when i switch out of full screen to normal, and then back to full screen again the custom view "fullscreenView" will not register... any thoughts?
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
ok... i was able to get it to start working by adding this to the mainWindow.m:

Code:
- (void)awakeFromNib {
		[self setContentView:fullscreenView];
}

however, is there anyway to add the setContentView code to the init? or does it not matter?
You have to do it in awakeFromNib: instead of init: because windows and views are UI Nib elements and won't be valid in init:. They are guaranteed to be valid in awakeFromNib:. Anytime you are modifying or hooking up UI elements, you probably want to do that in awakeFromNib:.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.