Re: How do I save and restore a custom NSTextAttachmentCell?
Re: How do I save and restore a custom NSTextAttachmentCell?
- Subject: Re: How do I save and restore a custom NSTextAttachmentCell?
- From: Douglas Davidson <email@hidden>
- Date: Thu, 17 Nov 2005 09:44:04 -0800
On Nov 17, 2005, at 7:00 AM, Michael wrote:
That sounds good. But one question left to solve this puzzle for
me: How do I load this data (RTFD + own data file) back into a
NSTextView and instantiate my own NSTextAttachmentCell-subclasses?
I assume I have to scan the attributed string and replace the cells
of my custom attachments with instances of my own cell classes? Is
this right or is there a more appropriate way?
If you simply load the RTFD in the usual way, you will get
NSTextAttachments with the contents of your custom file types.
Remember that by default NSTextAttachment will, on demand, create a
default NSTextAttachmentCell based on its idea of the contents of the
file--in this case, that would probably just be an icon. If you want
instead to use a custom image or a custom cell, you can scan through
the attributed string looking for the NSAttachmentAttributeName
attribute, check to see whether the attachment has a file of your
custom type, and if so set the attachment cell for that attachment.
It would probably be easiest to do this at load time, before the
document is ever displayed, although with a little extra work it
could be done lazily.
Douglas Davidson
_______________________________________________
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