Re: Inserting Graphics into NSTextView
Re: Inserting Graphics into NSTextView
- Subject: Re: Inserting Graphics into NSTextView
- From: Douglas Davidson <email@hidden>
- Date: Tue, 8 Apr 2003 16:41:38 -0700
On Tuesday, April 8, 2003, at 10:01 AM, email@hidden wrote:
How does one insert artwork (NSImage usually) into an NSTextView. I
can find
documentation talking about inserting a Attachment (file wrapper) to an
Attribute String, and inserting that into a NSTextView, but not how to
insert
an NSImage (the image is NOT associated with a file). Does one try to
create
a Glyph (that does not seem suited for inserting graphics either)?
An NSTextAttachment is a generic way of introducing images or other
drawing into the body of text. It is often, but not necessarily,
associated with an NSFileWrapper; you can certainly create one without
an NSFileWrapper (pass nil for it). For an arbitrary NSTextAttachment,
the text system will by default create a suitable NSTextAttachmentCell
with a suitable image, based on its own notions of suitability for the
type of file supplied, or a default image if there is none.
If you wish to supply your own image, you can either (a) allow the text
system to create an NSTextAttachmentCell, then set the image of that
cell, or (b) supply an NSTextAttachmentCell yourself. The latter can
be either of a standard kind, in which case you can again set its
image, or else some custom subclass, if you wish to do arbitrary
drawing within the text rather than simply supplying an image.
Note that if the text in question is saved as RTFD or copied to the
pasteboard, attachments will usually be represented by their
corresponding file wrappers; if you do not supply a file wrapper, there
may not be anything to be copied.
Note also that the presence of a file wrapper does not imply the
presence of a file; a file wrapper can be created with a file, but it
can also be created with a file's contents, without there being an
actual file in the file system.
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.