Make wxGrid cells selecting by mouse more user friendly

This commit is contained in:
Ilya Sinitsyn
2020-03-04 23:32:23 +07:00
committed by Vadim Zeitlin
parent 0920a1646b
commit 8ebdf101b8

View File

@@ -4492,13 +4492,6 @@ wxGrid::DoGridCellDrag(wxMouseEvent& event,
case wxMOD_CONTROL: case wxMOD_CONTROL:
if ( isFirstDrag ) if ( isFirstDrag )
SetGridCursor(coords); SetGridCursor(coords);
if ( m_selection )
{
m_selection->ExtendOrCreateCurrentBlock(m_currentCellCoords,
coords,
event);
MakeCellVisible(coords);
}
break; break;
case wxMOD_NONE: case wxMOD_NONE:
@@ -4513,20 +4506,13 @@ wxGrid::DoGridCellDrag(wxMouseEvent& event,
return performDefault; return performDefault;
} }
} }
if ( m_selection )
{
m_selection->ExtendOrCreateCurrentBlock(m_currentCellCoords,
coords,
event);
MakeCellVisible(coords);
}
break; break;
default:
// we don't handle the other key modifiers
event.Skip();
} }
// Edit the current selection block independently of the modifiers state.
if ( m_selection )
m_selection->ExtendOrCreateCurrentBlock(m_currentCellCoords, coords, event);
return performDefault; return performDefault;
} }
@@ -4566,10 +4552,7 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
return; return;
} }
if ( !event.CmdDown() ) if ( event.ShiftDown() && !event.CmdDown() )
ClearSelection();
if ( event.ShiftDown() )
{ {
if ( m_selection ) if ( m_selection )
{ {
@@ -4584,7 +4567,7 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
DisableCellEditControl(); DisableCellEditControl();
MakeCellVisible( coords ); MakeCellVisible( coords );
if ( event.CmdDown() ) if ( event.CmdDown() && !event.ShiftDown() )
{ {
if ( m_selection ) if ( m_selection )
{ {
@@ -4607,6 +4590,8 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
} }
else else
{ {
ClearSelection();
if ( m_selection ) if ( m_selection )
{ {
// In row or column selection mode just clicking on the cell // In row or column selection mode just clicking on the cell
@@ -4632,8 +4617,8 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
m_waitForSlowClick = m_currentCellCoords == coords && m_waitForSlowClick = m_currentCellCoords == coords &&
coords != wxGridNoCellCoords; coords != wxGridNoCellCoords;
SetCurrentCell( coords );
} }
SetCurrentCell(coords);
} }
} }