Re: NSWindowController confusion redux
Re: NSWindowController confusion redux
- Subject: Re: NSWindowController confusion redux
- From: Ken Tozier <email@hidden>
- Date: Mon, 22 May 2006 04:02:53 -0400
Well I thought I had this one licked, but apparently not.
I can open a panel nib programatically using NSWindowController and
it appears on screen, but calling [[windowController] window] is
still returning nil. In frustration, I deleted the whole nib and did
the following:
1. In interfaceBuilder, I created a new "empty" nib
2. Changed the custom class of the "files owner" object to
NSWindowController.
3. Created a new panel by dragging from the "Cocoa windows" tab
4. Set the following window attributes
Visible at launch
Utility window
Has shadow
5. Dragged a connection from the file owner to the window and
connected them.
6. Saved the nib and compiled the project
7. Launched the app, selected the menu command that opens the palette
Result: Window opens but calling [[windowController] window] says the
window is null
Any help/insights would be very appreciated.
Thanks in advance
Ken
Here's the relevant code from the class that creates the window
controller:
- (id) initWithBundle:(NSBundle *) inBundle
{
self = [super init];
if (self == nil)
return nil;
mainPaletteController = [[NSWindowController alloc]
initWithWindowNibName: @"MainPalette" owner: self];
return self;
}
Here's the code that shows and hides the palette
- (void) showPalette
{
NSLog(@"mainPaletteController = %@", mainPaletteController);
NSLog(@"mainPaletteController->window = %@", [mainPaletteController
window]);
[[mainPaletteController window] orderFront: self];
}
- (void) hidePalette
{
NSLog(@"mainPaletteController = %@", mainPaletteController);
NSLog(@"mainPaletteController->window = %@", [mainPaletteController
window]);
[[mainPaletteController window] orderOut: self];
}
And here's what appears in the log window
2006-05-22 04:00:58.646 QuarkXPress[22834] entered
XTShowCommandPalette command
2006-05-22 04:00:58.646 QuarkXPress[22834] gPaletteController:
<XTPluginController: 0x19eacc0>
2006-05-22 04:00:58.647 QuarkXPress[22834] mainPaletteController =
<NSWindowController: 0x19f85c0>
2006-05-22 04:00:58.647 QuarkXPress[22834] mainPaletteController-
>window = (null)
2006-05-22 04:01:00.898 QuarkXPress[22834] entered
XTHideCommandPalette command
2006-05-22 04:01:00.898 QuarkXPress[22834] gPaletteController:
<XTPluginController: 0x19eacc0>
2006-05-22 04:01:00.898 QuarkXPress[22834] mainPaletteController =
<NSWindowController: 0x19f85c0>
2006-05-22 04:01:00.898 QuarkXPress[22834] mainPaletteController-
>window = (null)
On May 14, 2006, at 12:11 AM, Ken Tozier wrote:
I'm loading a panel from a nib file using NSWindowController's
initWithWindowNibName. If I call the method "showWindow", the
panel appears on screen as expected but, even after this success,
calling the controller's "window" method returns nil. How do I
access the window the controller just opened if not through the
"window" method?
In your nib, make sure the "File's Owner" custom class is
NSWindowController. Once the class is right, the owner should have
an outlet named "window" that you need to connect to your panel.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden