Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing NSTableCellView's objectValue in view-based NSOutlineView does not propagate to dataSource

I use a view-based NSOutlineView to display and select hierarchically structured items for a scientific application.

view-based NSOutlineView

Each row in the outline column represents an item, signified by an item-specific icon (all the same in the picture), a checkbox that shows if the item is selected, and the name of the item. I need the icon, the checkbox and the name to appear in the same cell, hence I am using a view-based NSOutlineView.

I have implemented the NSOutlineViewDataSource protocol to supply data to the the outline view.

The method outlineView:objectValueForTableColumn:byItem: supplies a custom object that has the properties BOOL selected and NSString *name.

My custom table cell view in IB is composed as follows:

view-based NSOutlineView in IB

I bound the check box value to objectValue.selected and the label value to objectValue.name.

As I hoped, the outline view displays nicely the name and selection state supplied by the objectValue.

However, if I change the state of the check box, the method outlineView:setObjectValue:forTableColumn:byItem: that is defined in the NSOutlineViewDataSource protocol is not triggered in my dataSource to supply the newly changed object value. Note that if I don't use a custom view for the cell this works.

I checked whether the table cell view's objectValue.selected actually gets changed when clicking the check box by inserting an NSLog statement into the setSelected method of the object that is passed as objectValue. The selected member changes state correctly.

How do I propagate the change of the objectValue back to my dataSource's model? I have checked the NSOutlineView's delegate methods, but can't find a way to signal that the cell view's objectValue was changed by my check box (i.e., that the cell view has "ended editing"). Is there some other fundamental point I am missing?

like image 786
timo Avatar asked Nov 05 '22 11:11

timo


1 Answers

setObjectValue doesnt work for view based ones:

from header::

/* View Based OutlineView: This method is not applicable.
 */
- (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
like image 98
Daij-Djan Avatar answered Nov 13 '22 05:11

Daij-Djan