The previous answer is incorrect, because NSTextField / NSSearchField themselves do not become the first responder and process the edited text. Instead, they use the window's field editor, which is an NSTextView that is shared between all the fields of the window (since only one of them can have focus at a time).
You need to see if the first responder is an NSText , and if so, if the search field / text field is its delegate.
NSResponder *firstResponder = [[NSApp keyWindow] firstResponder]; if ([firstResponder isKindOfClass:[NSText class]] && [(id)firstResponder delegate] == mySearchField) { NSLog(@"Yup."); }
Greg titus
source share