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

Soulstorm

macrumors 68000
Original poster
Feb 1, 2005
1,887
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?
 

Attachments

  • cocoaki 1.zip
    39.3 KB · Views: 130

Soulstorm

macrumors 68000
Original poster
Feb 1, 2005
1,887
1
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.
 

wittegijt

macrumors member
Feb 18, 2007
31
0
Eindhoven
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.
 

Soulstorm

macrumors 68000
Original poster
Feb 1, 2005
1,887
1
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.

That sure helped a lot. Thank you very much!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.