0

I'm using an NSPopupButton in my OS X app to present the user with a list of choices. I'm populating it like this:

[baudButton removeAllItems];
[baudButton addItemWithTitle:(@"Baud")];
[baudButton addItemWithTitle:(@"600")];
[baudButton addItemWithTitle:(@"1200")];
[baudButton addItemWithTitle:(@"2400")];

Is there a way to visually mark the selection, or should I use another control?

Mike
  • 301
  • 4
  • 16
  • If you look at the docs for `[NSMenuItem setState: NSOnState/NSOffState]`, which would put/remove a check mark on the menu item, does that answer your question? – Smilin Brian Dec 17 '12 at 22:49
  • Yes, that would be acceptable. It seems like it would be a bit messy to implement, having to find and remove an existing check mark and add a new one if the selection changed. I'm unclear on how to use the ValidateMenuItem method too. More playtime needed, having a hard time translating the doc to something useful to me. – Mike Dec 18 '12 at 00:18
  • Can you clarify "if the selection changed"? As is, an NSPopUpButton will display a check mark next to the NSMenuItem chosen by a user's click or the NSPopUpButton `selectItem` methods. Do you mean that changes to a different object should change the NSPopUpButton's selectedItem? You can do that by [binding the NSPopUpButton to an Array Controller.](http://www.springenwerk.com/2009/09/nspopupbutton-with-fixed-values-and.html) – John Sauer Dec 18 '12 at 04:54
  • I mean if the user selects another item in the button's menu. If the button's type is set to "Dropdown" the check mark is not automagically displayed. The type must be set to "PopUp". – Mike Dec 19 '12 at 02:13

1 Answers1

0

Setting the NSPopUpButton's type attribute to "Popup" gave me a checkmark on the selected item, and displays the item on the "closed" button.

Mike
  • 301
  • 4
  • 16