Permalink
Browse files

Merge pull request #2467 from daboe01/tableview-cell-editing-fix-2-take

Fixed: tableview corruption when clicking on a cell-based control during an editing session
  • Loading branch information...
2 parents 315a7b9 + bb2a9fe commit 1360caaa8133c34a7f4ae6b5d1a7330219f43598 @mrcarlberg mrcarlberg committed on GitHub Sep 1, 2016
Showing with 13 additions and 17 deletions.
  1. +13 −17 AppKit/CPTableView.j
View
@@ -5097,14 +5097,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
}
}
else if (!_isViewBased && [aView isKindOfClass:[CPControl class]] && ![aView isKindOfClass:[CPTextField class]])
- {
- [self getColumn:@ref(column) row:@ref(row) forView:aView];
-
- _editingColumn = column;
- _editingRow = row;
-
[aView addObserver:self forKeyPath:@"objectValue" options:CPKeyValueObservingOptionOld | CPKeyValueObservingOptionNew context:"editing"];
- }
return aView;
}
@@ -5236,7 +5229,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
if (!_isViewBased)
{
[self _setEditingState:NO forView:textField];
- [self _commitDataViewObjectValue:textField];
+ [self _commitDataViewObjectValue:textField forColumn:_editingColumn andRow:_editingRow];
}
else
[textField setBezeled:NO];
@@ -5286,19 +5279,19 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
The action for any dataview that supports editing. This will only be called when the value was changed.
The table view becomes the first responder after user is done editing a dataview.
*/
-- (void)_commitDataViewObjectValue:(id)aDataView
+- (void)_commitDataViewObjectValue:(id)aDataView forColumn:(CPInteger)column andRow:(CPInteger)row
{
- var editingTableColumn = _tableColumns[_editingColumn];
+ var editingTableColumn = _tableColumns[column];
if (_implementedDataSourceMethods & CPTableViewDataSource_tableView_setObjectValue_forTableColumn_row_)
- [_dataSource tableView:self setObjectValue:[aDataView objectValue] forTableColumn:editingTableColumn row:_editingRow];
+ [_dataSource tableView:self setObjectValue:[aDataView objectValue] forTableColumn:editingTableColumn row:row];
// Allow the column binding to do a reverse set. Note that we do this even if the data source method above
// is implemented.
- [editingTableColumn _reverseSetDataView:aDataView forRow:_editingRow];
+ [editingTableColumn _reverseSetDataView:aDataView forRow:row];
- if (_editingRow !== CPNotFound && _editingColumn !== CPNotFound)
- [self reloadDataForRowIndexes:[CPIndexSet indexSetWithIndex:_editingRow] columnIndexes:[CPIndexSet indexSetWithIndex:_editingColumn]];
+ if (row !== CPNotFound && column !== CPNotFound)
+ [self _reloadDataForRowIndexes:[CPIndexSet indexSetWithIndex:row] columnIndexes:[CPIndexSet indexSetWithIndex:column]];
}
- (void)_setEditingState:(BOOL)editingState forView:(CPView)aView
@@ -5348,9 +5341,12 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
if (context === "editing" && [object superview] === self)
{
[object removeObserver:self forKeyPath:keyPath];
- [self _commitDataViewObjectValue:object];
- _editingRow = CPNotFound;
- _editingColumn = CPNotFound;
+
+ var row,
+ column;
+
+ [self getColumn:@ref(column) row:@ref(row) forView:object];
+ [self _commitDataViewObjectValue:object forColumn:column andRow:row];
}
}

0 comments on commit 1360caa

Please sign in to comment.