NSPopUpButtonCell Problems

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

  1. macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    Messages:
    1,885
    #1
    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. macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    Messages:
    1,885
    #2
    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. macrumors member

    Joined:
    Feb 18, 2007
    Messages:
    31
    Location:
    Eindhoven
    #3
    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:

    -(void)awakeFromNib
    {
    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?

    Wittegijt.
     
  4. macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    Messages:
    1,885
    #4
    That sure helped a lot. Thank you very much!
     

Share This Page