Jav*_*rán 1 xcode cocoa objective-c keydown nssearchfield
我有一个包含许多商店和 NSSearchfield 的视图,如果用户在搜索字段中按向上箭头,我想对商店做一些有趣的事情。我想在不子类化的情况下执行此操作,因为我在访问其他类的出口时遇到一些问题
编辑:我的插座问题是我无法从我的子类中更改它们的字符串值
if ([event keyCode]==126){
Myclass* c= [[Myclass alloc] init]; // the class that have the outlets
[c searchf];} //function that something interesting with the outlets
Run Code Online (Sandbox Code Playgroud)
您可以使用一个委托方法:
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command {
if (control == yourSearchField && command == @selector(moveUp:)) {
// do custom stuff
return YES;
}
return NO;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
586 次 |
| 最近记录: |