NSPopUpButtonCell Problems

Discussion in 'Mac Programming' started by Soulstorm, Mar 14, 2007.

  1. Soulstorm macrumors 68000


    Feb 1, 2005
    I am trying to understand custom table views, but I am stuck into a problem concerning NSPopUpButtonCells.

    I have a tableview that contains 2 columns: The first one, holds an NSSTring, and the second one an NSPopUpButton. For some reason, I can't get the popup button to work with a default menu set by me.

    When I clicked build and run, I expected to see a tableview that contained one object with an NSString as a name, and a PopupButton with some choices. Instead, I see no choices in the popup button.

    To assist me, I have made a BaseClass, that will hold an NSPopUpButtonCell and an NSSTring. I give you the example project.

    Can anyone see the project and see what I am doing wrong?

    Attached Files:

  2. Soulstorm thread starter macrumors 68000


    Feb 1, 2005
    I am starting to get desperate. I even tried to work with NSPopUpButtons in my BaseClass instead of NSPopUpButtonCells, but the result remained the same.

    Any help would be appreciated.
  3. wittegijt macrumors member

    Feb 18, 2007
    I don't really understand what you are trying to do. Why don't you simply add your popupmenu once and then get the selection from the datasource? It doesn't really make sense to keep the whole menu in the datasource.
    To create your menu:

    NSTableColumn *column = [tableView tableColumnWithIdentifier:mad:"menu"];
    NSPopUpButtonCell *popupButtonCell = [[[NSPopUpButtonCell alloc] initTextCell:mad:""] autorelease];
    [popupButtonCell setEditable:YES]; [popupButtonCell setBordered:NO];
    [popupButtonCell addItemsWithTitles:[NSArray arrayWithObjects:mad:"item1", @"item2", @"item3", nil]];
    [column setDataCell:popupButtonCell];

    Does that help?

  4. Soulstorm thread starter macrumors 68000


    Feb 1, 2005
    That sure helped a lot. Thank you very much!

Share This Page