在代码中将 Cocoa Paste 到 NSTextView
感谢您的帮助。
我只需要通过操作将剪贴板/粘贴板的内容粘贴到 NSTextView 中。
NSString *PboardType = @"PboardType";
- (IBAction)paste:sender
{
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSData *copiedData = [pb dataForType:PboardType];
[self RTFFromRange:copiedData];
}
最后一行显然是错误的。我需要做什么?
谢谢
保罗
Thanks for the help.
I just need to paste the contents of the clipboard/pasteboard to an NSTextView by way of an action.
NSString *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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有什么。 NSTextView 已经支持粘贴(以及剪切和复制、字体、搜索、拼写检查等)。您无需执行任何操作即可实现它。
如果您正在实现一些不同的粘贴行为,您应该编辑您的问题以指定您想要实现的特殊行为(以及为什么用户希望您的应用程序执行一些不寻常的操作)。
如果标准粘贴行为不起作用,您应该编辑您的问题以指定它不起作用的原因。
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.