On Jun 22, 2005, at 3:11 PM, Ian was here wrote: I'm trying to get a reference to an NSImage that already exists within an NSTextView. I've been through the documentation, and am not quite clear on it. I would appreciate any ideas.
Attachments are stored in the text as follows: there is an NSAttachmentCharacter (the Unicode substitution character), with the NSAttachmentAttributeName attribute, the value of which is an NSTextAttachment. The NSTextAttachment has an NSFileWrapper, which stores the contents of the attached file, and an NSTextAttachmentCell, which draws an appropriate representation inline in the text.
By default the text system will create an appropriate cell based on its notion of the contents of the attached file, typically displaying either the contents of the file as an image, or an icon for the file type, although there are other possibilities. If the cell in fact is displaying an image, then you can obtain it by asking the NSTextAttachment for its attachmentCell, and the cell for its image.
The default behavior can, of course, be altered or overridden; it is possible to supply a custom attachment cell, which can do more or less arbitrary drawing to represent the attachment. However, it seems from your question that you are dealing with the default behavior and with an attached file that actually is an image and so would be represented by an image cell.
Douglas Davidson
|