[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Help with NSTableView and NSPopUpButtonCell
From: |
Philippe Roussel |
Subject: |
Help with NSTableView and NSPopUpButtonCell |
Date: |
Sun, 21 Feb 2010 21:56:24 +0100 |
Hi all,
For the task view in SimpleAgenda I'm using a NSTableView with 2
columns, the first one using an NSPopUpButtonCell.
The code to set/get the cells' values hasn't change for a while (I
think) but I can't get it to work with gnustep-gui 0.17.1. I can set the
value correctly using the popup but the popup buttons don't show the
selected value.
This is how I set the cell for this column :
NSPopUpButtonCell *cell = [NSPopUpButtonCell new];
[cell addItemsWithTitles:[Task stateNamesArray]];
[[taskView tableColumnWithIdentifier:@"state"] setDataCell:cell];
and the setter/getter :
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
Task *task = [[_sm allTasks] objectAtIndex:rowIndex];
if ([[aTableColumn identifier] isEqualToString:@"summary"])
return [task summary];
/* this doesn't work */
/* [task state returns an interger between 0 and 3 */
return [NSNumber numberWithInt:[task state]];
}
/* I think the following works */
- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
Task *task = [[_sm allTasks] objectAtIndex:rowIndex];
if ([[task store] writable]) {
[task setState:[anObject intValue]];
[[task store] update:task];
}
}
Any ideas ?
You can get the latest code with 'svn co
svn://coyote.octets.fr/gnustep/SimpleAgenda/trunk SimpleAgenda'
Thanks,
Philippe
--
http://www.aworldofwishes.net/wish/23/
- Help with NSTableView and NSPopUpButtonCell,
Philippe Roussel <=