mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-11 21:27:11 +00:00
Bindings support for inline table view cell editing.
This commit is contained in:
@@ -646,6 +646,38 @@ CPTableColumnUserResizingMask = 1 << 1;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reverseSetDataView:(CPView)aDataView forRow:(unsigned)aRow
|
||||
{
|
||||
var bindingsDictionary = [CPBinder allBindingsForObject:self],
|
||||
keys = [bindingsDictionary allKeys],
|
||||
newValue = [aDataView valueForKey:@"objectValue"];
|
||||
|
||||
for (var i = 0, count = [keys count]; i < count; i++)
|
||||
{
|
||||
var bindingName = keys[i],
|
||||
bindingPath = [aDataView _replacementKeyPathForBinding:bindingName],
|
||||
binding = [bindingsDictionary objectForKey:bindingName],
|
||||
bindingInfo = binding._info,
|
||||
destination = [bindingInfo objectForKey:CPObservedObjectKey],
|
||||
keyPath = [bindingInfo objectForKey:CPObservedKeyPathKey],
|
||||
dotIndex = keyPath.lastIndexOf(".");
|
||||
|
||||
if (dotIndex === CPNotFound)
|
||||
[[destination valueForKeyPath:keyPath] replaceObjectAtIndex:aRow withObject:newValue];
|
||||
else
|
||||
{
|
||||
var firstPart = keyPath.substring(0, dotIndex),
|
||||
secondPart = keyPath.substring(dotIndex + 1),
|
||||
firstValue = [destination valueForKeyPath:firstPart];
|
||||
|
||||
if ([firstValue isKindOfClass:CPArray])
|
||||
[[firstValue objectAtIndex:aRow] setValue:newValue forKeyPath:secondPart];
|
||||
else
|
||||
[[firstValue valueForKeyPath:secondPart] replaceObjectAtIndex:aRow withObject:newValue];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- (void)objectValue
|
||||
//{
|
||||
// return nil;
|
||||
|
||||
+10
-3
@@ -3370,7 +3370,12 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
{
|
||||
_editingCellIndex = nil;
|
||||
|
||||
[_dataSource tableView:self setObjectValue:[sender objectValue] forTableColumn:sender.tableViewEditedColumnObj row:sender.tableViewEditedRowIndex];
|
||||
if (_implementedDataSourceMethods & CPTableViewDataSource_tableView_setObjectValue_forTableColumn_row_)
|
||||
[_dataSource tableView:self setObjectValue:[sender objectValue] forTableColumn:sender.tableViewEditedColumnObj row:sender.tableViewEditedRowIndex];
|
||||
|
||||
// Allow the column binding to do a reverse set. Note that we do this even if the data source method above
|
||||
// is implemented.
|
||||
[sender.tableViewEditedColumnObj reverseSetDataView:sender forRow:sender.tableViewEditedRowIndex];
|
||||
|
||||
if ([sender respondsToSelector:@selector(setEditable:)])
|
||||
[sender setEditable:NO];
|
||||
@@ -4139,10 +4144,12 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
}
|
||||
}
|
||||
|
||||
// Accept either tableView:setObjectValue:forTableColumn:row: delegate method, or a binding.
|
||||
if (mouseIsUp
|
||||
&& (_implementedDataSourceMethods & CPTableViewDataSource_tableView_setObjectValue_forTableColumn_row_)
|
||||
&& !_trackingPointMovedOutOfClickSlop
|
||||
&& ([[CPApp currentEvent] clickCount] > 1))
|
||||
&& ([[CPApp currentEvent] clickCount] > 1)
|
||||
&& ((_implementedDataSourceMethods & CPTableViewDataSource_tableView_setObjectValue_forTableColumn_row_)
|
||||
|| [self infoForBinding:@"content"]))
|
||||
{
|
||||
columnIndex = [self columnAtPoint:lastPoint];
|
||||
if (columnIndex !== -1)
|
||||
|
||||
Reference in New Issue
Block a user