Make the line whose header was Ctrl-clicked current

This is more consistent with Ctrl-clicking cells.

It also slightly improves behaviour when Ctrl-dragging mouse over the
range of selected lines, although it's still somewhat surprising.
This commit is contained in:
Vadim Zeitlin 2020-04-13 14:47:44 +02:00
parent 62cb90b455
commit da84a25311

View File

@ -3726,7 +3726,8 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event, wxGridRowLabelWindo
if ( m_selection && m_numRows > 0 && m_numCols > 0 && if ( m_selection && m_numRows > 0 && m_numCols > 0 &&
m_selection->GetSelectionMode() != wxGridSelectColumns ) m_selection->GetSelectionMode() != wxGridSelectColumns )
{ {
bool selectNewRow = false; bool selectNewRow = false,
makeRowCurrent = false;
if ( event.ShiftDown() && !event.CmdDown() ) if ( event.ShiftDown() && !event.CmdDown() )
{ {
@ -3743,23 +3744,28 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event, wxGridRowLabelWindo
else if ( event.CmdDown() && !event.ShiftDown() ) else if ( event.CmdDown() && !event.ShiftDown() )
{ {
if ( GetSelectedRows().Index(row) != wxNOT_FOUND ) if ( GetSelectedRows().Index(row) != wxNOT_FOUND )
{
DeselectRow(row); DeselectRow(row);
makeRowCurrent = true;
}
else else
{
makeRowCurrent =
selectNewRow = true; selectNewRow = true;
}
} }
else else
{ {
ClearSelection(); ClearSelection();
makeRowCurrent =
selectNewRow = true; selectNewRow = true;
} }
if ( selectNewRow ) if ( selectNewRow )
{
// Select the new row.
m_selection->SelectRow(row, event); m_selection->SelectRow(row, event);
if ( makeRowCurrent )
SetCurrentCell(row, GetFirstFullyVisibleColumn()); SetCurrentCell(row, GetFirstFullyVisibleColumn());
}
ChangeCursorMode(WXGRID_CURSOR_SELECT_ROW, rowLabelWin); ChangeCursorMode(WXGRID_CURSOR_SELECT_ROW, rowLabelWin);
} }
@ -4125,7 +4131,8 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event, wxGridColLabelWindo
if ( m_selection && m_numRows > 0 && m_numCols > 0 && if ( m_selection && m_numRows > 0 && m_numCols > 0 &&
m_selection->GetSelectionMode() != wxGridSelectRows ) m_selection->GetSelectionMode() != wxGridSelectRows )
{ {
bool selectNewCol = false; bool selectNewCol = false,
makeColCurrent = false;
if ( event.ShiftDown() && !event.CmdDown() ) if ( event.ShiftDown() && !event.CmdDown() )
{ {
@ -4142,23 +4149,28 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event, wxGridColLabelWindo
else if ( event.CmdDown() && !event.ShiftDown() ) else if ( event.CmdDown() && !event.ShiftDown() )
{ {
if ( GetSelectedCols().Index(col) != wxNOT_FOUND ) if ( GetSelectedCols().Index(col) != wxNOT_FOUND )
{
DeselectCol(col); DeselectCol(col);
makeColCurrent = true;
}
else else
{
makeColCurrent =
selectNewCol = true; selectNewCol = true;
}
} }
else else
{ {
ClearSelection(); ClearSelection();
makeColCurrent =
selectNewCol = true; selectNewCol = true;
} }
if (selectNewCol) if ( selectNewCol )
{
// Select the new column.
m_selection->SelectCol(col, event); m_selection->SelectCol(col, event);
if ( makeColCurrent )
SetCurrentCell(GetFirstFullyVisibleRow(), col); SetCurrentCell(GetFirstFullyVisibleRow(), col);
}
ChangeCursorMode(WXGRID_CURSOR_SELECT_COL, colLabelWin); ChangeCursorMode(WXGRID_CURSOR_SELECT_COL, colLabelWin);
} }