Cocoa Paste to NSTextView in code
Thanks for the help.
I just need to paste the contents of the clipboard/pasteboard to an NSTextView by way of an action.
NSSt开发者_运维百科ring *PboardType = @"PboardType";
- (IBAction)paste:sender
{
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSData *copiedData = [pb dataForType:PboardType];
[self RTFFromRange:copiedData];
}
The last line is obviously wrong. what do I need to do?
Thanks
Paul
Nothing. An NSTextView already supports pasting (and cutting and copying, and fonts, and search, and spelling-checking, and …). You don't need to do anything to implement it.
If you're implementing some different paste behavior, you should edit your question to specify what special behavior you're trying to achieve (as well as why the user will want your application to do something unusual).
If the standard paste behavior isn't working, you should edit your question to specify how it isn't working.
精彩评论