Re: NSDocument and stationery
Re: NSDocument and stationery
- Subject: Re: NSDocument and stationery
- From: Christopher Corbell <email@hidden>
- Date: Tue, 23 Sep 2003 18:01:00 -0700
Thanks for your help, this did the trick from the app's perspective.
I did find however that it made a difference where I set
the fileName to nil - I could not do it when loading data because
the window was not yet hooked up (setFileName notifies the window
controller), so I check the stationery bit when the document's window is
actually being shown.
Has Apple given up on keeping the Finder savvy about stationery?
Since a modern app has no 'SIZE' resource, there appears to be
no way to set the isStationeryAware bit, so the Finder will always
duplicate stationery files when they're double-clicked.
I found that even AppleWorks 6 fails to work in this regard (the
Finder's copy gets opened).
I understand that one can create a different document type for
templates (as AppleWorks does), but then this defeats the use
of the stationery bit altogether...
- Christopher
On Monday, September 22, 2003, at 11:59 AM, Greg Titus wrote:
On Sep 22, 2003, at 11:17 AM, Christopher Corbell wrote:
Is there any support for stationery files with
NSDocument, or is there any Cocoa equivalent for
making a document behave as a template for an new
untitled document with content?
It isn't built in to NSDocument, no, but it is fairly easy to hook
into NSDocumentController to add it. If you link with OmniAppKit
you'll get this behavior, for instance.
You just need to replace the implementation of the
NSDocumentController -openDocumentWithContentsOfFile:display: method,
call the original implementation, then check to see if the file has
the stationary pad bit set. If so, just reset the filename to nil.
You can see the code in NSDocumentController-OAExtensions.m for more
details.
Or if you want to do it in your own NSDocument subclass, just
determine when you load the file whether it is a stationary pad or not
(using the Carbon FSpGetFInfo() call), and call [self setFileName:nil]
if it is.
Hope this helps,
- Greg
_______________________________________________
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.
_______________________________________________
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.