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

Aranince

macrumors 65816
Original poster
Apr 18, 2007
1,104
0
California
I'm trying to create a preference window, but I am having a problem bringing the window "back to life." When I first launch the program and open the pref window, it opens fine. I then close the pref window and try to open it again and no window pops up. How do I get the window to come back up after I close it? Here is how I open it in the first place through the window controller:

Code:
-(void)showPreferenceWindow:(id)sender
{
	[NSApp activateIgnoringOtherApps:YES];
	[[self window] center];
	[[self window] makeKeyAndOrderFront:nil];	
}

...and in the NSWindow subclass I just have

Code:
-(void)awakeFromNib
{
	[self setHidesOnDeactivate:NO];
	[self setReleasedWhenClosed:NO];
}
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Are you sure awakeFromNib is being called? Is [self window] non-nil? Don't assume things are what you think they are. Use the debugger or logging :)
 

Aranince

macrumors 65816
Original poster
Apr 18, 2007
1,104
0
California
awakeFromNib is being called...[self window] is nil(assuming I'm checking it correctly: [self window] == nil ) and the window controller's init method is being called and succeeding.

My init method for the controller

Code:
-(id)init
{
	if((self = [super initWithWindowNibName:@"GHPreferences"]))
	{

	}
	return self;
}

Why would self window be nil? It's nil the first time I open the pref window...which I find strange. Does [self window] not exist until I call makeKeyAndOrderFront?

EDIT: I tried if([self isWindowLoaded] == NO) and the case is only true once.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.