Embedding custom attachment cell in a NSTextView
Embedding custom attachment cell in a NSTextView
- Subject: Embedding custom attachment cell in a NSTextView
- From: Denis Delbecq <email@hidden>
- Date: Sat, 19 Nov 2005 16:25:16 +0100
Hello,
I try to use a NSTextAttachment in a NSTextView, to embed text notes
in my documents. I use for that a NSTextAttachmentCell that points to
a custom class object designed to deal with notes, using
setRepresentedObject. Then, when I double-click on the icon of the
note, using [cell representedObject], the text it contains displays
itself in a small panel. This works perfectly.
Unfortunately, when I copy/paste or drag&drop some text which
contains a NSTextAttachment, the icon displays itself, but I get an
error when I double-click on it. In fact, the copy of the
NSTextAttachment object (when copy/paste) or the displaced
NSTextAttachment object (when drag&drop) returns nil when accessing
the cell representedObject method. As if the copy/Paste and Drag/Drop
operations lost the memory of this representedObject.
I tried then to use a subclass of NSTextAttachmentCell, adding a id
noteContent item and wrote two methods (setNoteContent and
getNoteContent) to access to this data. When creating a
NSTextAttachment, I allocate/retain a custom attachmentCell object
and send a setAttachmentCell: myAttachmentCell message to the
attachment. This works also.
But when double-clicking the icon after a copy/paste or a drag/drop
operation, the cell I get using
textView:doubleClickedOnCell:inRect:atIndex: in the delegate
implementation belongs to NSTextAttachmentCell class, instead of my
custom AttachmentCell class. So, it doesn't understand the
getNoteContent message I send to get the note object I defined and I
get an error.
I read a lot of contribution in this mailing list archive and visited
many cocoa dev websites but didn't find anything. I just read a
contribution from Keith Blount that explains he succeeded to
implement the same feature but he didn't give any explanation.
Could somebedy help me for this problem?
Regards
Denis Delbecq
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden