This question seems straightforward but I've tried everything I can think of, and Googled for hours.
I have an NSSearchField that does autocomplete, basically copying Apple's SearchField sample code. I have turned off "Sends Whole Search String" in IB because I don't want to do the search until the user has finalized their text entry, and don't want to do multiple searches (they are expensive).
As the user types in the field, when they press enter, specifying that they accept the current autocompletion, I want the action for the NSSearchField to fire. Instead, it just seems to fill-in the autocompletion, then the user has to press enter a second time for the action to fire. Basically, think of starting to type in a URL in Safari, it autocompletes, and pressing enter starts loading the page (firing the action). They don't need to press enter a second time to start loading the page.
Things I've tried without success:
- control:textView:commandSelector:, looking for insertNewline:. It doesn't get fired when they are pressing enter to finish the autocompletion
- Overriding controlTextDidEndEditing:. Same as above
Any ideas? Thanks!
See Question&Answers more detail:os