Re: Suggesting an initial filename with document-based app?
Re: Suggesting an initial filename with document-based app?
- Subject: Re: Suggesting an initial filename with document-based app?
- From: Eric Wang <email@hidden>
- Date: Thu, 03 Jul 2003 03:57:19 -0400
on 7/2/03 6:19 PM, Matt Gemmell at email@hidden wrote:
>
Hi there,
>
>
I have a document-based application, and I'd like to suggest a filename
>
when the user first saves a document. I believe I can detect if it's the
>
first time a document has been saved by checking if the document's
>
window's representedFilename is the empty string (right?), but I'm
>
unsure how to actually cause the Save panel to show my suggested
>
filename.
>
>
NSDocument's -saveDocumentWithDelegate:... gets called before the panel
>
is run, and I see no way to specify a filename there, and
>
-saveToFile:... is run after the user has chosen a name/location in the
>
panel, and I obviously don't want to override their choice.
>
-prepareSavePanel gives me access only to the save panel object itself,
>
which offers no way to set an initial title before running it. None of
>
the NSSavePanel delegate methods allow me to specify an initial
>
filename.
>
>
What part of the NSDocument saving machinery do I need to override in
>
order to suggest an initial filename (say, based on the document's
>
contents)? Or is there more involved in order to achieve this?
>
>
Cheers,
>
-Matt
Hi Matt,
Here's one way that might work:
- (BOOL) prepareSavePanel: (NSSavePanel *) savePanel
{
if ([self fileName] == nil)
{
NSForm *form = [[savePanel contentView] viewWithTag:
NSFileHandlingPanelForm];
// Here you can customize the form however you want
}
return YES;
}
Eric Wang
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.