简体   繁体   中英

how to copy all attributed content from NSTextView to NSPasteboard

I'm trying to implement auto copy content from NSTextView to clipboard for pasting it in editor in the future. NSTextView has plain and attributed text and images.

If I select all and copy by pressing CMD+C and paste to some rich editor (for example Mail.app) everything is fine.

I found this solution to copy RTF on CocoaDev.com

But when I'm trying to copy my content through this solution is nothing happening if I pasting then in editor.

How to copy attributed text with images from NSTextView textStorage to NSPasteboard?

所需要的就是使用NSRTFDPboardType。

Your text view's text storage is an instance of NSTextStorage, which is a subclass of NSMutableAttributedString. With that in mind, look at Copy NSAttributedString to pasteboard and you'll have everything you need to move forward.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM