From ee0b70a3a9d5010bba589db71b973d7e13a0b581 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 13 Apr 2020 21:41:40 +0200 Subject: [PATCH] Disable extending selection with Ctrl-drag for rows/columns too Don't extend the selection if the anchor line is not selected, as this doesn't work correctly because the entire selection logic supposes the anchor itself is selected and, moreover, it's not really clear how could it would otherwise. This commit does the same thing for rows/columns as the grandparent commit did to the cells. Unfortunately a somewhat cleaner solution of the parent commit can't be easily applied to the existing rows/columns code and it's arguably not worth changing it in depth just for this. --- src/generic/grid.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 1f7927614e..d2f7a68f1e 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -3673,6 +3673,11 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event, wxGridRowLabelWindo if ( !m_selection || m_numRows == 0 || m_numCols == 0 ) break; + // We can't extend the selection from non-selected row, + // which may happen if we Ctrl-clicked it initially. + if ( !m_selection->IsInSelection(m_currentCellCoords) ) + break; + if ( (row = YToRow( pos.y )) >= 0 ) { m_selection->ExtendCurrentBlock( @@ -4016,6 +4021,12 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event, wxGridColLabelWindo if ( !m_selection || m_numRows == 0 || m_numCols == 0 ) break; + // We can't extend the selection from non-selected + // column which may happen if we Ctrl-clicked it + // initially. + if ( !m_selection->IsInSelection(m_currentCellCoords) ) + break; + m_selection->ExtendCurrentBlock( wxGridCellCoords(0, m_currentCellCoords.GetCol()), wxGridCellCoords(GetNumberRows() - 1, col),