Re: NSTextView Copy-and-Paste Problem

2015-03-02 Thread Martin Wierschin
 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSTextView Copy-and-Paste Problem

2015-03-02 Thread Charles Jenkins
Thanks, Martin.

The docs say you can put anything you want into the attributes 
dictionary—without mentioning that cutting and pasting will screw it all up. 
But it makes sense why, if cutting and pasting involves a translation into some 
non-native format. I’ll try to learn how to override cutting and pasting to 
make them include the full attributes.

-- 

Charles

On March 2, 2015 at 16:43:51, Martin Wierschin (mar...@nisus.com) wrote:

 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSTextView Copy-and-Paste Problem

2015-03-02 Thread Charles Jenkins
Can I convince anyone to look at my demo app and tell me what if anything I'm 
doing wrong?

I can hardly believe copying and pasting in a text view would lose or replace 
attributes like this . . . seems like a very serious bug someone would have 
noticed long before me.

-- 

Charles

On February 28, 2015 at 06:25:39, Charles Jenkins (cejw...@gmail.com) wrote:

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 fought the Swift battle to create a quick-and-dirty demonstration app which, 
if you are so inclined, you can check out from GitHub:

https://github.com/CharlesJenkins/TextViewRevealer/tree/master

(This is my first foray into GitHub, so let me know if something is missing 
from my project.)

I’d like to know if this behavior is expected or a bug, or if there is 
something else I’m supposed to do in my code to make copying and pasting work 
better by faithfully copying text attributes.

— 

Charles
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSTextView Copy-and-Paste Problem

2015-02-28 Thread Charles Jenkins
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 fought the Swift battle to create a quick-and-dirty demonstration app which, 
if you are so inclined, you can check out from GitHub:

https://github.com/CharlesJenkins/TextViewRevealer/tree/master

(This is my first foray into GitHub, so let me know if something is missing 
from my project.)

I’d like to know if this behavior is expected or a bug, or if there is 
something else I’m supposed to do in my code to make copying and pasting work 
better by faithfully copying text attributes.

— 

Charles
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com