tags:

views:

103

answers:

1

I have a xib file with a main window and a panel. On awakeFromNib I try to orderFront the main window, but the panel keeps being key window.

- (void)awakeFromNib {
[inspectionPanelOutlet orderBack:self];
[inspectionPanelOutlet orderWindow:NSWindowBelow relativeTo:0];
[window makeKeyAndOrderFront:self];
}

This code has no effect.

A: 

Are you sure awakeFromNib is called (add an NSLog message and see if it fires)? If it is called you might want to try:

[self makeMainWindow];

or

[self makeKeyWindow];
Elise van Looij
first one crashes2009-12-18 12:42:49.235 MacSkirmish[3034:10b] An uncaught exception was raised2009-12-18 12:42:49.236 MacSkirmish[3034:10b] Invalid parameter not satisfying: [self canBecomeMainWindow]2009-12-18 12:42:49.236 MacSkirmish[3034:10b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: [self canBecomeMainWindow]'second one has no effect:(
Ronaldo Nascimento
Not sure why you're getting that error. But anyway, my answer violated the principle I try to program by: Don't fix it if it ain't broke. If you select the panel in Interface Builder and look at its attributes you'll see in the section "Behavior" a checkbox named "Visible At Launch". Check this for the main window, uncheck it for the panel and remove all that stuff from the awakeFromNib. If you want to learn how to show the panel by clicking a button check out <a href="http://developer.apple.com/mac/library/samplecode/FancyAbout/index.html#//apple_ref/doc/uid/DTS10000390">FancyAbout</a>.
Elise van Looij