NSTextView 委托不起作用?
我有一个 NSTextView,我将委托交给我的文件所有者。然后,我的文件所有者与一个类相关联,我在该类中在视图中执行不同的操作。
据我了解,现在应该可以从我的类中的 NSTextView 捕获事件(因为我已将其委托设置为文件所有者),但它似乎不起作用,为什么呢?
我在我的班级中实现了这个功能:
- (BOOL)control: (NSControl *)control textView:(NSTextView *)textView doCommandBySelector: (SEL)commandSelector {
NSLog(@"i was fired!");
return YES;
}
I have a NSTextView where i put the delegate to my file owner. My file owner is then assosiated with a class where i do different stuff in the view.
To my understanding it should now be possible to catch events from the NSTextView inside my class (because i have set its delegate to file owner), but it does not seem to work, why is that?
I have implemented this function in my class:
- (BOOL)control: (NSControl *)control textView:(NSTextView *)textView doCommandBySelector: (SEL)commandSelector {
NSLog(@"i was fired!");
return YES;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 http://developer.apple.com/library/mac/#documentation/cocoa/Reference/NSTextViewDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSTextViewDelegate
方法签名如下所示:
尝试一下吧。
according to http://developer.apple.com/library/mac/#documentation/cocoa/Reference/NSTextViewDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSTextViewDelegate
the method signature looks like:
give that a try instead.
选择器只是
textView:doCommandBySelector:
;放下控件
。The selector is just
textView:doCommandBySelector:
; drop thecontrol
.