• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Embedding custom attachment cell in a NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Embedding custom attachment cell in a NSTextView


  • Subject: Re: Embedding custom attachment cell in a NSTextView
  • From: Douglas Davidson <email@hidden>
  • Date: Mon, 28 Nov 2005 10:45:16 -0800


On Nov 19, 2005, at 7:25 AM, Denis Delbecq wrote:

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.


Copy/paste does not store the NSTextAttachmentCell; it only stores the NSTextAttachment's file wrapper. Copy/paste of text uses text document formats (RTFD, in this case) that store attachments as a placeholder in the text pointing to the contents of an attached file.


If you wish to be able to copy/paste a custom attachment, you should either (a) develop a file representation for your attachment, and use that as the contents of the attachment's file wrapper, taking care to provide an appropriate attachment cell on paste; or (b) add a custom pasteboard type whose contents are, for example, an archived version of an attributed string (rather than an RTFD version).

Keep in mind that copy/paste is an inter-application communication mechanism. Other applications will certainly not understand your custom attachments, so copy/paste by default cannot handle them. For intra-application use, you can either use a custom pasteboard type understood only by your application, or else give a custom interpretation to standard data such as text attachments.

Douglas Davidson

_______________________________________________
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


References: 
 >Embedding custom attachment cell in a NSTextView (From: Denis Delbecq <email@hidden>)

  • Prev by Date: Re: Is Apple's singleton sample code correct?
  • Next by Date: Re: webviw in a tab
  • Previous by thread: Embedding custom attachment cell in a NSTextView
  • Next by thread: Re: or Using NSImage... [was: Re: Using NSBundle]
  • Index(es):
    • Date
    • Thread