From 4e62b240423168c0e619dcb407653e12c537e5c1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 28 Jun 2020 22:58:20 +0200 Subject: [PATCH] Fix bug with Shift-Enter selecting cells while editing It was unexpected that pressing Shift-Enter while an editor was active didn't close it, but just selected the cell below (and then the one below it if pressed again and so on), so now always finish editing when it's pressed. It could be argued that it's still unexpected for Shift-Enter to select the cell below after closing the editor, but this is consistent with how Tab works, and so shouldn't be as confusing as the old behaviour. --- src/generic/grid.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index bad5babbb9..13e89994b6 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -5696,13 +5696,14 @@ void wxGrid::OnKeyDown( wxKeyEvent& event ) } else { - if ( !MoveCursorDown( event.ShiftDown() ) ) - { - // Normally this would be done by MoveCursorDown(), but - // if it failed to move the cursor, e.g. because we're - // at the bottom of a column, do it here. - DisableCellEditControl(); - } + // We want to accept the changes in the editor when Enter + // is pressed in any case, so do it (note that in many + // cases this would be done by MoveCursorDown() itself, but + // not always, e.g. it wouldn't do it when editing the + // cells in the last row or when using Shift-Enter). + DisableCellEditControl(); + + MoveCursorDown( event.ShiftDown() ); } break;