Search code examples
macoscocoanscombobox

How to make NSComboBox lose focus after selection?


I have a combo box in my OSX app and I want it to lose focus right after I change the value selection.

Right now it just stays selected and highlighted after the selection.

Any kind of help is highly appreciated!


Solution

  • Just figured this out myself.

    Using NSComboBoxDelegate, I use this method

    - (void)comboBoxWillDismiss:(NSNotification *)notification 
    

    It's getting called right before the pop-up list is going to be dismissed. Inside that method I'm calling:

    [myComboBox setRefusesFirstResponder:YES]; 
    

    and it does the trick.