Pasteboard inconsistencies
Pasteboard inconsistencies
- Subject: Pasteboard inconsistencies
- From: Randall Meadows <email@hidden>
- Date: Fri, 18 Apr 2008 12:07:58 -0600
I'm doing some manipulation of selected text and having some
inconsistencies, apparently based on what the *contents* of the text
is. I'm very confused about this, hopefully someone can set me
straight.
I'm using writeSelectionToPasteboard:types: to get the current text
selection, using a custom pasteboard ([NSPasteboard
pasteboardWithUniqueName]) and pass an array containing only
NSStringPboardType for "types".
That all works, I get the text using [pb
stringForType:NSStringPboardType], and I perform my manipulation on
it; I can see the results of it, and it's exactly what I expect. The
problem surfaces when I try to replace the selection with my new text.
I put the new text onto my custom clipboard using [pb
setString:newText forType:NSStringPboardType], and then replace the
selected text with [view readSelectionFromPasteboard:pb]. Now, for a
simple string like "asdf", this works just fine. The problem occurs
when the new text contains control characters, like a carriage return
or a tab character. In that case, the text is not replaced with the
new text I've just placed on my custom clipboard, but rather with the
contents of the general pasteboard (like what I see when I select Show
Clipboard from Finder's Edit menu).
Immediately after the setString call, I can 'po [pb
stringForType:NSStringPboardType]', and I see that my new text is
indeed there. Why come then is it taking the text from a totally
different pasteboard than what I specified, and even then only
*sometimes*, depending on whether there are control characters in the
text?
TIA!
randy
_______________________________________________
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