检测NSTextField上的粘贴 [英] Detect paste on NSTextField

查看:126
本文介绍了检测NSTextField上的粘贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对NSTextField进行粘贴操作.

I'm trying to handle a paste operation on a NSTextField.

我找到了类似文章,但对于NSTextView.我通过覆盖NSTextField并放置了以下代码来尝试与此类似的代码:

I found a similar article but for NSTextView. I tried code similar to this by overriding NSTextField and putting:

- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard
{
    return [super readSelectionFromPasteboard: pboard];
}

但是这种方法似乎永远不会被调用.

But this method seems to never be called.

关于如何在NSTextField上检测过去的任何建议?

Any suggestions on how to detect a past on NSTextField?

推荐答案

您可以使用NSTextFieldDelegate委托方法- (BOOL) control:(NSControl*) control textView:(NSTextView*) textView doCommandBySelector:(SEL) commandSelector并注意paste:选择器.

You could use the NSTextFieldDelegate delegate method - (BOOL) control:(NSControl*) control textView:(NSTextView*) textView doCommandBySelector:(SEL) commandSelector and watch for the paste: selector.

这篇关于检测NSTextField上的粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆