检测NSTextField上的粘贴 [英] Detect paste on 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屋!