Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Qaanol

macrumors 6502a
Original poster
Jun 21, 2010
571
11
I’m drawing a bit of a conceptual blank here. I want to make an NSTableView (cell-based) with two columns, both of which have popup buttons. The first column’s popup has options “ABC” and “1234”. When the user picks one of those options, the popup in the second column of the same row changes to have options {“A”, “B”, “C”} or {“1”, “2”, “3”, “4”} respectively.

What I’m having trouble with, is figuring out how to make the corresponding menu in the second column update when a selection is made in the first column.
 

Red Menace

macrumors 6502a
May 29, 2011
578
226
Colorado, USA
What I've done is set up a dictionary with keys and arrays representing the popups and their list items. Then I use the selection of the first popup as a key to look up the corresponding array values to put in the second popup.
 

Qaanol

macrumors 6502a
Original poster
Jun 21, 2010
571
11
What I've done is set up a dictionary with keys and arrays representing the popups and their list items. Then I use the selection of the first popup as a key to look up the corresponding array values to put in the second popup.

I think you are a few steps ahead of me. Do I need to manually create a separate NSPopUpButtonCell for each row, or is there a way to set the cell’s menu on a per-row basis?
 

Qaanol

macrumors 6502a
Original poster
Jun 21, 2010
571
11
Depends a bit on how you have set up your tableview, but take a look at this Stack Overflow article for some ideas.

I’ve read that discussion, it focuses on Cocoa bindings which I am not using. I have an object serving as data source and delegate for the table, which provides the things to be displayed. I had originally thought that since each row of the second column uses the same type of object, an NSPopUpButtonCell with a menu, that I could get away with just putting the cell in the table column, but now I think I actually need a distinct cell for each row.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.