Re: Replacing the standard NSTextAttachmentCell in an NSTextView
Re: Replacing the standard NSTextAttachmentCell in an NSTextView
- Subject: Re: Replacing the standard NSTextAttachmentCell in an NSTextView
- From: Douglas Davidson <email@hidden>
- Date: Tue, 6 Nov 2007 09:10:53 -0800
On Nov 6, 2007, at 6:34 AM, email@hidden wrote:
I'm currently researching how to provide a custom NSCell to replace
the current NSTextAttachentCell in an NSTextView.
The reason is that I want to have a different type of attachment not
just for images or file objects, but for actual objects in my
application.
IOW, something similar to NSTokens (actually I'm using an
NSTokenFieldCell subclass) that can represent actual "objects" in a
text field...
So, I have insertion working, and the cell fulfills the basic
protocol for NSTextAttachment.
The problem is, when cutting and pasting my object back into the
text field, it reverts to a standard NSTextAttachmentCell....
How can I override this to insert my special cell?
The problem I am running into is that the NSTextAttachment requires
an NSFileWrapper, but since I am not representing a file object, I
tested it out using:
NSTextAttachment *textAttachment = [[NSTextAttachment alloc]
initWithFileWrapper:nil];
In the above case, paste then doesn't even work....
The issue here has to do with the formats used to store text on the
pasteboard. Copy/paste can potentially take place between any two
applications, so the pasteboard generally uses application-independent
formats for the interchange of data. In this case, attachments are
stored for pasteboard purposes as file contents. One option for you
is to decide on a file format to represent the contents of your custom
attachments, and use that as the contents of the file wrapper for copy/
paste purposes. In this, you should consider what you want to happen
when text is copied and pasted from your application to another
application--is there some suitable representation for your custom
attachments that other applications would understand? Your
application could then recognize these files by some means--by
contents, or perhaps by extension--when they are pasted in, and
substitute your custom attachment.
Douglas Davidson
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden