From faf70706540d53d12630c9e277ee9a3f1909fe50 Mon Sep 17 00:00:00 2001 From: Alexander Malmberg Date: Thu, 27 Mar 2003 22:54:46 +0000 Subject: [PATCH] (-setSelectionFrom:to:anchor:highlight:): Update the selection related ivars after changing the selection. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16281 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/NSMatrix.m | 26 +++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) 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