I've got a two column tableview - column 0 is text, column 1 is popupcells. Everything seems fine but when I release the mouse when selecting from the popup, it momentarily displays the selection i made but it then resets back to item 0 (first item) in the menu list. I've gone over this million times. In my datasource class I have the 3 required routines. It all comes down to the fact that I can't get the selected item index - it always returns 0.
In the routine:
-(id)tableView: (NSTableView *) tableView objectValueForTableColumnNSTableColumn *) tableColumn row: (int) row
I do the following:
selection = [[tableColumn dataCell] indexOfSelectedItem];
this always returns 0. I have verified that I do indeed have the correct datacell by verifying it's itemArray. Everything checks out but the "indexOfSelectedItem" method always returns 0.
I manually set the returned value to "2" just to see if the pop up would get set to the third item - It does. I just can't get the dataCell to tell me what item is selected.
And then down in the other routine:
- (void)tableViewNSTableView *)aTableView setObjectValueid)anObject forTableColumnNSTableColumn *)aTableColumn rowNSInteger)rowIndex
if I manually set the value to 2 for example, my popup changes correctly. I am going nuts!
I am unsure of a couple of things; for a popup control in a listview, am I supposed to use the "setObjectValue" method or should the popupbuttoncell class take care of maintaining the currently displayed item?
For the text column, I am storing the values in an NSMutableArray. That's all working fine. But when my datasource is asked for the value of the popupmenu, i assume I have to return the current item index. If I manually return a value it responds correctly - but like I have said numerous times - i don't seem to be able to query the datacell for its currently selected index.
It's almost as if internally a copy of my datacell is being used but it is not a complete copy. It has all the right menuitems in it but for some reason it can't provide the currently selected item index.
All and all help with this would be greatly appreciated.
Thanks
In the routine:
-(id)tableView: (NSTableView *) tableView objectValueForTableColumnNSTableColumn *) tableColumn row: (int) row
I do the following:
selection = [[tableColumn dataCell] indexOfSelectedItem];
this always returns 0. I have verified that I do indeed have the correct datacell by verifying it's itemArray. Everything checks out but the "indexOfSelectedItem" method always returns 0.
I manually set the returned value to "2" just to see if the pop up would get set to the third item - It does. I just can't get the dataCell to tell me what item is selected.
And then down in the other routine:
- (void)tableViewNSTableView *)aTableView setObjectValueid)anObject forTableColumnNSTableColumn *)aTableColumn rowNSInteger)rowIndex
if I manually set the value to 2 for example, my popup changes correctly. I am going nuts!
I am unsure of a couple of things; for a popup control in a listview, am I supposed to use the "setObjectValue" method or should the popupbuttoncell class take care of maintaining the currently displayed item?
For the text column, I am storing the values in an NSMutableArray. That's all working fine. But when my datasource is asked for the value of the popupmenu, i assume I have to return the current item index. If I manually return a value it responds correctly - but like I have said numerous times - i don't seem to be able to query the datacell for its currently selected index.
It's almost as if internally a copy of my datacell is being used but it is not a complete copy. It has all the right menuitems in it but for some reason it can't provide the currently selected item index.
All and all help with this would be greatly appreciated.
Thanks