Fix extending selection starting from unselected current cell
Unselected current cell should always be considered as the current selection block to extend, as it doesn't make sense to extend any other block (perhaps selected on another side of the grid) when pressing Shift-arrow. This scenario could be achieved by selecting a block and Ctrl-clicking a cell (either inside or outside the selection) twice and then extending it using Shift-arrow keys. Previously, this behaved in a strange way, combining the corner of the selected block with the target of the movement, whereas now this just starts selecting a new block from the current cell as expected.
This commit is contained in:
parent
ddaa5b5e02
commit
5d90688723
@ -68,9 +68,11 @@ public:
|
||||
void UpdateCols( size_t pos, int numCols );
|
||||
|
||||
// Extend (or shrink) the current selection block (creating it if
|
||||
// necessary, i.e. if there is no selection at all currently) to the one
|
||||
// specified by the start and end coordinates of its opposite corners
|
||||
// (which don't have to be in top/bottom left/right order).
|
||||
// necessary, i.e. if there is no selection at all currently or if the
|
||||
// current current cell isn't selected, as in this case a new block
|
||||
// containing it is always added) to the one specified by the start and end
|
||||
// coordinates of its opposite corners (which don't have to be in
|
||||
// top/bottom left/right order).
|
||||
//
|
||||
// Note that blockStart is equal to wxGrid::m_currentCellCoords almost
|
||||
// always, but not always (the exception is when we scrolled out from
|
||||
|
@ -496,7 +496,11 @@ bool wxGridSelection::ExtendCurrentBlock(const wxGridCellCoords& blockStart,
|
||||
wxASSERT( blockStart.GetRow() != -1 && blockStart.GetCol() != -1 &&
|
||||
blockEnd.GetRow() != -1 && blockEnd.GetCol() != -1 );
|
||||
|
||||
if ( m_selection.empty() )
|
||||
// If selection doesn't contain the current cell (which also covers the
|
||||
// special case of nothing being selected yet), we have to create a new
|
||||
// block containing it because it doesn't make sense to extend any existing
|
||||
// block to non-selected current cell.
|
||||
if ( !IsInSelection(m_grid->GetGridCursorCoords()) )
|
||||
{
|
||||
SelectBlock(blockStart, blockEnd);
|
||||
return true;
|
||||
@ -649,7 +653,10 @@ wxGridCellCoords wxGridSelection::GetExtensionAnchor() const
|
||||
{
|
||||
wxGridCellCoords coords = m_grid->m_currentCellCoords;
|
||||
|
||||
if ( m_selection.empty() )
|
||||
// If the current cell isn't selected (which also covers the special case
|
||||
// of nothing being selected yet), we have to use it as anchor as we need
|
||||
// to ensure that it will get selected.
|
||||
if ( !IsInSelection(coords) )
|
||||
return coords;
|
||||
|
||||
const wxGridBlockCoords& block = *m_selection.rbegin();
|
||||
|
Loading…
Reference in New Issue
Block a user