diff --git a/ChangeLog b/ChangeLog index e02dc9768..64a3f6d0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-03-27 23:52 Alexander Malmberg + + * Source/NSMatrix.m (-setSelectionFrom:to:anchor:highlight:): Update + the selection related ivars after changing the selection. + 2003-03-27 Serg Stoyan * Source/NSMenuView.m: diff --git a/Source/NSMatrix.m b/Source/NSMatrix.m index f523dec5d..2729e5821 100644 --- a/Source/NSMatrix.m +++ b/Source/NSMatrix.m @@ -1211,7 +1211,6 @@ static SEL getSel; startIndex: startPos endIndex: selStart-1]; } - } else { @@ -1281,6 +1280,31 @@ static SEL getSel; endIndex: INDEX_FROM_COORDS(maxx_AS, miny_AE-1)]; } } + + /* + Update the _selectedCell and related ivars. This could be optimized a lot + in many cases, but the full search cannot be avoided in the general case, + and being correct comes first. + */ + { + int i, j; + for (i = _numRows - 1; i >= 0; i--) + { + for (j = _numCols - 1; j >= 0; j--) + { + if (_selectedCells[i][j]) + { + _selectedCell = _cells[i][j]; + _selectedRow = i; + _selectedColumn = j; + return; + } + } + } + _selectedCell = nil; + _selectedColumn = -1; + _selectedRow = -1; + } } - (id) cellAtRow: (int)row