2

Multiselect NSComboBox

Can we have a NSComboBox with multiple selection through checkboxes in OSx. Please find the attached image as an example.

Please help.

Utkarsha
  • 250
  • 2
  • 12
  • Please add some clarification. Do you want to change the menu of the combo box according to the selection of a radio buttons? – Daniel Farrell Jun 24 '15 at 07:40
  • @boyfarrell Thanks for replying, i have edited my question, does that helped to clarify my requirement? – Utkarsha Jun 24 '15 at 07:58
  • I recommend using an `NSPopUpButton` configured in pull-down mode and, as the user picks item, you adjust its title to reflect what's selected. – Ken Thomases Jun 24 '15 at 08:48
  • @KenThomases But how will you show multiple selection in NSPopUpButton? – Utkarsha Jun 24 '15 at 09:24
  • You can set the `state` of the menu items so they show a check mark. – Ken Thomases Jun 24 '15 at 10:06
  • You can add views to menu items. You can do this by making a custom view with a check box and a label and adding several of these views to the pop up buttons menu. However, this will look a bit odd on OS X as no other controls work like this on the platform. And Ken's suggestion is much simpler. A nice way to do this is with token text fields http://www.wannabegeek.com/?p=46 – Daniel Farrell Jun 24 '15 at 11:42
  • Thanks to all.. I have created a custom one by binding a tableview with the NSComboBox. – Utkarsha Jun 24 '15 at 12:39

1 Answers1

2

According to the NSComboBox class reference - the answer is NO.

as you can see on the Manipulating the Selection:

@property(readonly) NSInteger indexOfSelectedItem
@property(readonly, strong) id objectValueOfSelectedItem

- deselectItemAtIndex: 
- selectItemAtIndex:
- selectItemWithObjectValue:

they refer to the selected item as single selection.

so I'd suggest looking for a custom solution, like keeping the selections on a different array and binding it together.

Aviram Netanel
  • 12,633
  • 9
  • 45
  • 69