Fix selection expansion in row/column-only selection modes
We should never adjust the fixed coordinate of the selection blocks in this mode, so ensure we never end up with a partially selected line in this case by preserving the -- correct by construction -- current block coordinates in this direction.
This commit is contained in:
parent
32bb5e9157
commit
b10755e553
@ -498,6 +498,12 @@ bool wxGridSelection::ExtendOrCreateCurrentBlock(const wxGridCellCoords& blockSt
|
||||
const wxGridBlockCoords& block = *m_selection.rbegin();
|
||||
wxGridBlockCoords newBlock = block;
|
||||
|
||||
// Don't adjust the blocks rows at all in column selection mode as the
|
||||
// top/bottom row are always fixed to the first/last grid row anyhow in
|
||||
// this case and we shouldn't select only part of a column just because the
|
||||
// user Shift-clicked somewhere in the middle of the grid.
|
||||
if ( m_selectionMode != wxGrid::wxGridSelectColumns )
|
||||
{
|
||||
// If the new block starts at the same top row as the current one, the
|
||||
// end block coordinates must correspond to the new bottom row -- and
|
||||
// vice versa, if the new block starts at the bottom, its other end
|
||||
@ -530,8 +536,11 @@ bool wxGridSelection::ExtendOrCreateCurrentBlock(const wxGridCellCoords& blockSt
|
||||
if ( bottom > newBlock.GetBottomRow() )
|
||||
newBlock.SetBottomRow(bottom);
|
||||
}
|
||||
}
|
||||
|
||||
// Same as above but mirrored for columns.
|
||||
if ( m_selectionMode != wxGrid::wxGridSelectRows )
|
||||
{
|
||||
if ( blockStart.GetCol() == block.GetLeftCol() )
|
||||
{
|
||||
newBlock.SetRightCol(blockEnd.GetCol());
|
||||
@ -552,6 +561,7 @@ bool wxGridSelection::ExtendOrCreateCurrentBlock(const wxGridCellCoords& blockSt
|
||||
if ( right > newBlock.GetRightCol() )
|
||||
newBlock.SetRightCol(right);
|
||||
}
|
||||
}
|
||||
|
||||
newBlock = newBlock.Canonicalize();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user