Re: NSWindowController MyDocument not appearing
Re: NSWindowController MyDocument not appearing
- Subject: Re: NSWindowController MyDocument not appearing
- From: Chris Hanson <email@hidden>
- Date: Sun, 6 May 2007 22:06:35 -0700
On May 6, 2007, at 9:07 AM, Soares wrote:
When I implement the above I lose "My Document" window. I suspect it
has
something to do with File Owner's or some such thing from what I
have read
on the subject, but I'm a little confused by what's going on.
You need to change MyDocument.nib so that your NSWindowController
subclass (in this case, SCOpenGLController) is the class of File's
Owner, rather than your NSDocument subclass. If you're using multiple
windows per document, you need to instantiate one window controller
per window.
SCOpenGLController.m contains the following excerpts and seems to
work fine,
and my custom panel appears as desired, but I never get the "My
Document"
window.
Any ideas?
- (id)init
{
if (self = [super initWithWindowNibName:@"MyDocument"])
{
[super initWithWindowNibName:@"SCOpenGL"];
Why are you doing this? You've already invoked an appropriate
superclass initializer. This is probably the primary source of your
application's confusion.
Each document in the application has two windows:
1. Outline View <- File's owner is set to MyDocument
2. Opengl View <- File's owner is set to SCOpenGLController
Each window controller manages a window, not multiple windows. So you
should be creating a window controller for each window in your -
[MyDocument makeWindowControllers] method. You may not need a custom
window controller for your main document window, so you could just do
something like this:
- (void)makeWindowControllers {
mainWindowController = [[NSWindowController alloc]
initWithWindowNibName:@"MyDocument"];
[self addWindowController:mainWindowController]
scOpenGLWindowController = [[SCOpenGLController alloc] init];
[self addWindowController:scOpenGLWindowController];
}
And of course, you'd also change MyDocument.nib to have a File's Owner
of NSWindowController since it's no longer owned or managed by the
document itself.
-- Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden