Re: Convert PICT to NSImage (SOLVED)
Re: Convert PICT to NSImage (SOLVED)
- Subject: Re: Convert PICT to NSImage (SOLVED)
- From: Douglas Davidson <email@hidden>
- Date: Tue, 28 Jun 2005 09:45:35 -0700
On Jun 28, 2005, at 9:32 AM, Ian was here wrote:
NSTextAttachment *textAttachment = [[NSTextAttachment
alloc] init];
NSTextAttachmentCell *attCell =
[[[NSTextAttachmentCell alloc]
initImageCell:pictImage] autorelease];
[textAttachment setAttachmentCell:attCell];
[[textView textStorage]
appendAttributedString:[NSAttributedString
attributedStringWithAttachment:textAttachment]];
Bear in mind that an NSTextAttachment has two principal components:
first, the NSFileWrapper, which represents the model portion--that
is, the actual attached file; second, the NSTextAttachmentCell, which
represents the view portion--that is, the drawing that represents
that file in the text.
By default--when you drag a file into a text view, for example--the
text system will create the cell based on the contents or type of the
file, usually either by interpreting it as an image, or by finding an
icon for it.
However, it is certainly possible to decouple these two components,
and to set a custom image or even a whole custom cell without regard
for the contents of the attached file. This is what you have done,
and it is an appropriate solution in many cases.
You must keep in mind, however, that if the text is selected and
copied, then what is copied over is the contents of the attached
file, not any custom image that you may have set on a cell, or custom
cell. Therefore, if you want the attachment to be able to be copied,
you must give it an NSFileWrapper to represent it in the persistent
representation used on the pasteboard.
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