• 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: NSTextView Copy-and-Paste Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView Copy-and-Paste Problem


  • Subject: Re: NSTextView Copy-and-Paste Problem
  • From: Martin Wierschin <email@hidden>
  • Date: Mon, 02 Mar 2015 13:43:50 -0800

> I’m having problems with text attributes getting mangled by copy-and-paste operations within the selfsame text view. Obviously text pasted in from outside the app would have an unpredictable set of attributes, but you’d think copying and pasting in the same text view would leave you with a consistent set of attributes.
…
> I’d like to know if this behavior is expected or a bug


I didn’t look long at your code, but from what I saw, the behavior is expected. You’re applying custom keys to the NSTextView/NSTextStorage that will not be serialized when copy-pasting.

By default when you select some text in NSTextView and trigger a copy action, the selected text will be vended on the pasteboard via some common data format (eg: HTML, RTF, DOCX, etc) so the content can be pasted into another application. Naturally these common data formats have no understanding of your custom attribute keys, and thus cannot encode them.

If you need to preserve you own custom attributes when copy-pasting within your app, you’ll need to override the copy-paste methods in your NSTextView subclass to add a custom pasteboard data type with higher priority.

~Martin


_______________________________________________

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


  • Follow-Ups:
    • Re: NSTextView Copy-and-Paste Problem
      • From: Charles Jenkins <email@hidden>
References: 
 >Re: NSTextView Copy-and-Paste Problem (From: Charles Jenkins <email@hidden>)

  • Prev by Date: NSTextField highlight
  • Next by Date: Re: Force IKImageBrowserView to regenerate a cell's image?
  • Previous by thread: Re: NSTextView Copy-and-Paste Problem
  • Next by thread: Re: NSTextView Copy-and-Paste Problem
  • Index(es):
    • Date
    • Thread