I have a view with many outlets and a NSSearchfield, i want to do something interesting with the outlets if the user press up arrow in the searchfield. I want to do this without subclassing because i have some problems accesing the outlets from other class
EDIT: My problem with the outlets is that i can't change their stringvalue from my subclass
if ([event keyCode]==126){
M开发者_JAVA百科yclass* c= [[Myclass alloc] init]; // the class that have the outlets
[c searchf];} //function that something interesting with the outlets
There's a delegate method you can use:
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command {
if (control == yourSearchField && command == @selector(moveUp:)) {
// do custom stuff
return YES;
}
return NO;
}
精彩评论