From bfca68c74ad581dbc10513521e90625e615bc778 Mon Sep 17 00:00:00 2001 From: Ilya Sinitsyn Date: Sat, 28 Mar 2020 00:49:45 +0700 Subject: [PATCH] Move the wxGrid cursor to the corner of the last selection Move the wxGrid cursor to the corner of the last selection when splitting the selection block on click with Ctrl. --- src/generic/grid.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index f24c68499e..f67bd960b8 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -4567,6 +4567,10 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event, DisableCellEditControl(); MakeCellVisible( coords ); + // Whether we should move the current grid cell to the corrner of the + // last selected block. + bool goToLastBlock = false; + if ( event.CmdDown() && !event.ShiftDown() ) { if ( m_selection ) @@ -4585,6 +4589,8 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event, wxGridBlockCoords(coords.GetRow(), coords.GetCol(), coords.GetRow(), coords.GetCol()), event); + + goToLastBlock = true; } } } @@ -4618,7 +4624,16 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event, m_waitForSlowClick = m_currentCellCoords == coords && coords != wxGridNoCellCoords; } - SetCurrentCell(coords); + + if ( goToLastBlock && m_selection->IsSelection() ) + { + wxGridBlockCoords& lastBlock = m_selection->GetBlocks().back(); + SetCurrentCell(lastBlock.GetTopLeft()); + } + else + { + SetCurrentCell(coords); + } } }