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.
This commit is contained in:
Vadim Zeitlin
2020-04-13 21:41:40 +02:00
parent e6186f73a6
commit ee0b70a3a9

View File

@@ -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),