Re: NSTextAttachment
Re: NSTextAttachment
- Subject: Re: NSTextAttachment
- From: Alexander Reichstadt <email@hidden>
- Date: Tue, 17 Jul 2012 00:43:35 +0200
There is a blog that outlines how to do this with help of Douglas Davidson:
http://www.dejal.com/blog/2007/11/cocoa-custom-attachment-text-view
The suggestion here is to use a textStorage delegate to insert the custom attachment cell into the text. It actually relies on what seems like a bug:
if ([attachment isKindOfClass:[NSTextAttachment class]] &&
![[attachment attachmentCell] isKindOfClass:[TATextAttachmentCell class]])
{
This is happening in
- (void)textStorageWillProcessEditing:(NSNotification *)note
What I don't understand is that before it's a TATextAttachment with a TATextAttachmentCell, being my subclasses, and afterwards when pasting/dropping and looking at the debugger, the objects become NSTextAttachment and its cell respectively. Why? And how can I make it stop it from turning my subclasses into their superclasses?
Am 16.07.2012 um 23:51 schrieb Jens Alfke:
>
> On Jul 16, 2012, at 2:15 PM, Alexander Reichstadt <email@hidden> wrote:
>
>> Is there any way to have an NSTextView to hold text and custom data-widgets that are unrelated to filewrappers? I don't want NSTextAttachmentCell I think, because without a file it doesn't work
>
> I have used NSTextAttachmentCell for things that are not files. Note the comment in NSTextAttachment.h that says "An NSTextAttachment *usually* has a fileWrapper" (emphasis mine). It doesn't *have* to have one.
>
> Unfortunately it's been enough years that I don't remember the details. It may be that you can initialize an NSTextAttachment with a nil fileWrapper, or to set the fileWrapper property to nil after initialization. If not, you may just be able to pass in an arbitrary path to some file, and then the NSTextAttachmentCell methods such that they don't care what the file is.
>
> —Jens
_______________________________________________
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