Re: How to get NSImage into an NSMutableAttributedString ?
Re: How to get NSImage into an NSMutableAttributedString ?
- Subject: Re: How to get NSImage into an NSMutableAttributedString ?
- From: Douglas Davidson <email@hidden>
- Date: Mon, 1 Dec 2003 14:04:46 -0800
On Dec 1, 2003, at 12:54 PM, Bob Miller wrote:
This may be a simple operation but, I've yet to figure it out and
haven't been able to find an answer for this one anywhere .I hope
someone can help. Does anyone know if it is possible to insert an
NSImage reference into an NSAttributedStrin so that it becomes
'attached' and gets displayed within the string similar as it would if
an image file was dragged from the desktop for instance ? Is it even
possible to insert and NSImage into an NSAttributedString (Mutable
that is) ?
Yes, certainly. Attachments appear in text as an NSAttachmentCharacter
with an NSAttachmentAttributeName attribute, whose value is an
NSTextAttachment. The content of the NSTextAttachment is handled by an
NSFileWrapper, which is used when saving the text, copying/pasting, and
so forth. The rendering of the NSTextAttachment is handled by an
NSTextAttachmentCell. If you are only interested in display, then you
can supply a cell for your text attachment and set its image to your
image of choice. If you are interested in having it save properly,
then you can supply file data for the NSFileWrapper; by default the
text system will create an appropriate cell, according to its own
notions, or you can supply one if you wish.
Douglas Davidson
_______________________________________________
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.