I am trying to make a CPTableColumn that can change values without having to click it. An Example is I am trying to have a slider show up in the table that when dragged will change the table value for the row.
In looking into the CPTableView I see that there is support for CPTextFields and CPButtons but I am not sure how to use any other control to allow inline editing of values.
Any help on this would be great.
You can easily add a slider to a table view, like this:
var dataColumn = [[CPTableColumn alloc] initWithIdentifier:"Slider"];
[table addTableColumn:dataColumn];
[[dataColumn headerView] setStringValue:"Slider (Editable)"];
[dataColumn setEditable:YES];
[dataColumn setWidth:140];
[dataColumn setDataView:[[CPSlider alloc] initWithFrame:CGRectMakeZero()]];
The slider will automatically reflect the cell values read from your data source or binding as long as you make sure the values are numbers.
Unfortunately, as you noted, since the slider is not a button the table will not send tableView:setObjectValue:forTableColumn:row:
messages for it. You could subclass CPSlider
to have it return YES
to isKindOfClass:[CPButton class]
.
This rightly feels like a hack so for a better long term solution, check how Cocoa handles a CPSlider cell. If Cocoa sends tableView:setObjectValue:forTableColumn:row:
for the slider, go ahead and post up a feature request and include your little Cocoa test app to demonstrate it. Cappuccino strives to work the same way as Cocoa in these matters.