Call the function when the user presses the enter button in the NSSearchField?

I am surprised that I can not find the answer to this simple task. I just want the user to type the text, press enter, and the application knows what he typed. How should I do it?

+5
source share
1 answer

NSSearchFieldsupports the mechanism of action of the action, so just attach it to the goal / action. For example, suppose the following action is specified in the application deletion:

- (IBAction)searchAnswer:(id)sender;

Interface Builder ctrl- searchAnswer:. -stringValue, , ,

- (IBAction)searchAnswer:(id)sender {
    NSLog(@"search answer: %@", [searchField stringValue]);
}

, , / . , , Enter, Sends Whole Search String .

+16

All Articles