Quick question on popup buttons in tables

Discussion in 'Mac Programming' started by Qaanol, Apr 7, 2014.

  1. Qaanol macrumors 6502a

    Joined:
    Jun 21, 2010
    #1
    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.
     
  2. Red Menace macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #2
    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.
     
  3. Qaanol thread starter macrumors 6502a

    Joined:
    Jun 21, 2010
    #3
    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?
     
  4. Red Menace macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #4
  5. Qaanol thread starter macrumors 6502a

    Joined:
    Jun 21, 2010
    #5
    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.
     

Share This Page