On Jan 11, 2012, at 2:40 PM, James Merkel wrote: > > On Jan 11, 2012, at 8:39 AM, Ross Carter wrote: > >> On Jan 10, 2012, at 10:14 PM, James Merkel wrote: >> >>> the default NSParagraphStyle is being applied to my string. >> >> To be precise, a NSParagraphStyle is being applied to your attributed >> string. The NSString does not contain any formatting information. >> >> When you copy rich text, say from TextEdit, you place two sets of data on >> the pasteboard: the rich text data with the NSParagraphStyle and font >> information, and plain text data, which is just the characters. When you >> paste into a document, the receiving app chooses the item on the pasteboard >> that it wants to use. A code editor might prefer the plain text version, >> whereas a word processor would prefer the rich text version. >> >> If you want the text to line up neatly in an app that takes plain text from >> the pasteboard, you probably want to align everything using spaces, as Jens >> said. If you want the text to align in an app that uses rich text, you >> should use tabs and define their location using NSParagraphStyle. To handle >> both possibilities, you need to manage what gets put on the pasteboard. If >> you are using NSTextView, there are some pasteboard methods available for >> you to override. >> >> Ross > > I'm using my own defined NSParagraphStyle now for the tabstops and that works > fine. That's a cleaner and more maintainable approach than I was using > before. So thanks to Jens for that suggestion. > I would like to be able to copy and paste to TextEdit and maintain the > attributes (including bolded text). I'll take a look at the pasteboard > methods of NSTextView. > > Thanks > Jim Merkel > > Turns out, all I needed to do was check the "Allows Rich Text" check box in the NSTextView Attributes Inspector in Interface Builder to allow the two types of text (Rich Text and plain text) to be copied to the pasteboard. No coding required - excellent.
Jim Merkel _______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com