本文介绍了将点击操作添加到NSTextField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将事件附加到NSTextField,当我点击它?
解决方案
你可以试试这个:它适用于我。
@interface customTextField:NSTextField
@property(strong)id target;
@end
@implementation customTextField
- (void)mouseDown:(NSEvent *)theEvent
{
[self sendAction:@ selector(clickAction :) to:[self target]];
}
@end
How do I attach a event to a NSTextField for when I click on it? Are there any examples out there?
解决方案
You can try this: It works for me.
@interface customTextField : NSTextField
@property (strong) id target;
@end
@implementation customTextField
- (void)mouseDown:(NSEvent *)theEvent
{
[self sendAction:@selector(clickAction:) to:[self target]];
}
@end
Thanks.
这篇关于将点击操作添加到NSTextField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!