Re: NSDocument/NSSavePanel and controlling filenames
Re: NSDocument/NSSavePanel and controlling filenames
- Subject: Re: NSDocument/NSSavePanel and controlling filenames
- From: Chris Giordano <email@hidden>
- Date: Fri, 28 Jan 2005 09:10:31 -0600
Rob,
On Jan 27, 2005, at 4:32 PM, Robert Martin wrote:
Is there a way to set filenames in a savePanel in response to the user
selecting different formats?
Where the file is saved is up to the user - but the filename is not
really up to the user to choose - it is determined by values inside
the document - (because most applications that use the output file
treat the filename as a key) - and different formats require different
permutations. When the user clicks on a different format, I'd like to
provide instant feedback on the name change.
I can easily set an initial filename for a specific format during the
prepareSavePanel delegate method. But when the user selects a
different format, I cannot figure out how to make the SavePanel
display the new computed name. I can change the document's type and
filename, but this seems to have no immediate effect on the savePanel.
By the time panel:userEnteredFilename:confirmed: is called, it's too
late to change the filename.
Is it possible to use the standard classes for this, or do I have to
subclass NSSavePanel?
Apologies if I'm missing something obvious, but I can't find anything
in the archives.
Thanks, Rob
Not sure if this would work, but given my understanding of what you're
doing I'd take a slightly different approach.
First, if I'd probably try to use an NSOpenPanel to have the user
select the location and set it to only allow selection of directories
([op setCanChooseDirectories:YES]; [op setCanChooseFiles:NO];). This
way there isn't a filename to specify (since you provide that), and
since the filename isn't something the user should change (if I read
your message correctly), it makes sense to not have the user able to
change it.
Then, to specify the filename, if you override NSDocument's
-writeToFile:ofType:, you can specify the filename there by yourself.
It might also be a good thing to provide some feedback to the user in
the open panel -- either by setting the title somehow, or using an
accessory view to display the name of the file.
Then, it would probably just be a matter of overriding the
saveDocument... methods to use your open panel and handle things
appropriately (setFileName:, setFileType:,
updateChangeCount:NSChangeCleared, etc.).
Again, no idea if this actually would work, but if it were me I'd start
with this and see how far I could get with it.
Hope this helps.
chris
_______________________________________________
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