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: mmalcolm crawford <email@hidden>
- Date: Wed, 2 Jul 2003 17:33:13 -0700
I wrote:
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?
- (BOOL)prepareSavePanel:(NSSavePanel *)savePanel {
if ([self fileName] == nil) {
[self setFileName:NSLocalizedString(@"MyDefaultFileName",
@"custom default filename")];
}
return YES;
}
Matt (privately) pointed out that the problem with using this method by
itself is that, if the user cancels the Save dialog, the document then
still has the suggested filename (and window title).
One way around this might be to implement the following two methods:
-
(void)runModalSavePanelForSaveOperation:(NSSaveOperationType)saveOperati
on delegate:(id)delegate didSaveSelector:(SEL)didSaveSelector
contextInfo:(void *)contextInfo
{
[super
runModalSavePanelForSaveOperation:(NSSaveOperationType)saveOperation
delegate:self
didSaveSelector:@selector(document:didSave:contextInfo:)
contextInfo:[self fileName]];
}
- (void)document:(NSDocument *)doc didSave:(BOOL)didSave
contextInfo:(void *)contextInfo {
if (!didSave) {
[self setFileName:contextInfo];
}
}
If anyone has a better suggestion, I'd be pleased to hear it...
mmalc
_______________________________________________
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.