PDA

View Full Version : NSPopUpButtonCell Problems




Soulstorm
Mar 14, 2007, 08:02 AM
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?



Soulstorm
Mar 14, 2007, 09:43 AM
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
Mar 14, 2007, 02:46 PM
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:@"menu"];
NSPopUpButtonCell *popupButtonCell = [[[NSPopUpButtonCell alloc] initTextCell:@""] autorelease];
[popupButtonCell setEditable:YES]; [popupButtonCell setBordered:NO];
[popupButtonCell addItemsWithTitles:[NSArray arrayWithObjects:@"item1", @"item2", @"item3", nil]];
[column setDataCell:popupButtonCell];
}


Does that help?

Wittegijt.

Soulstorm
Mar 14, 2007, 03:42 PM
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:@"menu"];
NSPopUpButtonCell *popupButtonCell = [[[NSPopUpButtonCell alloc] initTextCell:@""] autorelease];
[popupButtonCell setEditable:YES]; [popupButtonCell setBordered:NO];
[popupButtonCell addItemsWithTitles:[NSArray arrayWithObjects:@"item1", @"item2", @"item3", nil]];
[column setDataCell:popupButtonCell];
}


Does that help?

Wittegijt.

That sure helped a lot. Thank you very much!