Re: "Visible at Launch" again, with "least" example
Re: "Visible at Launch" again, with "least" example
- Subject: Re: "Visible at Launch" again, with "least" example
- From: Erik Buck <email@hidden>
- Date: Wed, 4 Jul 2007 11:46:26 -0400
Thanks, Patrick, but I did indeed wind up rewriting the window
handler to not open a window at all until the EULA has been agreed to.
Given all of the developers who may be moving from Carbon to Cocoa as
a result of the 64-bit business, the IB team should probably redefine
what "Visible at Launch" is labelled with, as most will, like me,
assume that it gives control over visibility (there's a single
setting in a "traditional" Mac OS window to affect visibility, and
it's pretty much absolute. It doesn't appear that there's any such
thing for a NSDocument window.)
"Visible at launch time" absolutely effects whether a window defined
in a nib is visible when the nib is first loaded. I recommend
playing around with IB for two minutes to get a hang for that behavior.
I suspect that there is a misapprehension about what happens when a
nib is loaded by the Cocoa document infrastructure. I have never
seen Apple implementation of the relevant classes, but I assume the
document architecture loads the nib that defines the document
interface AND THEN EXPLICITLY MAKES THE DOCUMENT WINDOW VISIBLE like
the following: (look for // !!! The magic line that supersedes
"Visible at launch time" !!!)
NSWindowContrller's assumed implementation
- (id)window
{
if(nil == window)
{
[self windowWillLoad];
[[self document] windowControllerWillLoadNib:self];
[self loadWindow];
[self windowDidLoad];
[[self document] windowControllerDidLoadNib:self];
}
}
- (void)loadWindow
{
// Note: loading the nib initializes the window instance variable
[NSBundle loadNibNamed:[self windowNibName] owner:[self document]];
}
NSDocument's assumed default implementation
- (void)makeWindowControllers
{
if(nil != [self windowNibName])
{
NSWindowController *newWindowController = [[[NSWindowController
alloc]
initWithWindowNibName:[self windowNibName] autorelease];
[newWindowController setDocument:self];
[self addWindowController: newWindowController];
// !!! The magic line that supersedes "Visible at launch
time" !!!
[[newWindowController window] makeKeyAndOrderFront:nil];
}
}
The good news is that if you don't like Cocoa's default document
infrastructure, you are free to use your own. There is no magic
involved. Apple's TextEdit sample implements its own document
infrastructure. The book, "Cocoa Programming" implements a simple
document infrastructure just to demystify the process.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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