Re: NSDocument newbie
Re: NSDocument newbie
- Subject: Re: NSDocument newbie
- From: John Stiles <email@hidden>
- Date: Tue, 26 Jul 2005 18:27:59 -0700
On Jul 26, 2005, at 6:11 PM, James Bucanek wrote:
John Stiles wrote on Tuesday, July 26, 2005:
Now I have another NSDocument question. Instead of having my app open
up with a meaningless blank document, I'd like for it to start up
showing the Open dialog. How can I do this? Or at the very least, how
can I make the empty document at startup go away?
To stop NSApp from trying to create a new window when the
application is launched, define
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication*)sender
in your application delegate and just return NO.
My application doesn't prompt for an open dialog when it is opened,
but I image that you could catch applicationDidFinishLaunching: and
call, or queue up a call to, openDocument:.
In fact, I did just that.
If it's already open with no windows open, I'd like to make a click
in the dock icon bring back the Open panel as well, but that one
stumped me. I tried having applicationShouldOpenUntitledFile: do the
following check:
if( [[[NSDocumentController sharedDocumentController] documents]
count] == 0 )
{
[[NSDocumentController] sharedDocumentController]
openDocument:self];
}
This almost worked. But if you clicked the dock icon, clicked the
desktop, and clicked the dock icon again, you'd get multiple open
panels simultaneously. Doh. So I just did openDocument in the
applicationDidFinishLaunching for now.
_______________________________________________
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