I have a NSPopUpButton
. Whenever I add or remove items to it, the first item gets automatically selected. I want to inhibit this; I want the NSPopUpButton
to appear with nothing selected, and to not select anything itself until the user selects something.
Everything is being constructed in code. (This is a backend; the GUI layout comes from elsewhere.)
NSComboBox
does this already.
With NSTableView
, I used an NSArrayController
and Cocoa bindings, so I could just do:
[ac setSelectsInsertedObjects:NO]; // for insertions
[ac setAvoidsEmptySelection:NO]; // for deletions
I tried this with NSPopUpButton
, however, and that did not change the behavior: the first item is still automatically selected.
I have also tried accessing the backing NSMenu
at someone on IRC's suggestion and adding to that; the behavior did not change.
I noticed there's a method on NSPopUpButton
, synchronizeTitleAndSelectedItem
, that seems to do exactly what I said NSPopUpButton
does itself, but I don't see a way to disable it, either in NSPopUpButton
or NSPopUpButtonCell
. Am I going to have to subclass NSPopUpButton
to make this method do nothing? I'm not particularly attracted to that idea.
Is there something else I'm doing wrong? Thanks.