From 1208aa116a8c4dd2b0d6103939a12b8a732d64f1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 20 Jun 2020 19:52:43 +0200 Subject: [PATCH] Accept space as starting key for editing numbers in wxGrid Not being able to use space for starting editing the values of the numeric columns was inconsistent with most (if not all) the other ones and so surprising and inconvenient. Make space work for these columns too, but just ignore it, i.e. in particular do not erase the current cell contents when it's pressed, to avoid changing the old behaviour too much. --- src/generic/grideditors.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/generic/grideditors.cpp b/src/generic/grideditors.cpp index ae7eff24ae..af1a11cae1 100644 --- a/src/generic/grideditors.cpp +++ b/src/generic/grideditors.cpp @@ -836,10 +836,19 @@ bool wxGridCellNumberEditor::IsAcceptedKey(wxKeyEvent& event) if ( wxGridCellEditor::IsAcceptedKey(event) ) { int keycode = event.GetKeyCode(); - if ( (keycode < 128) && - (wxIsdigit(keycode) || keycode == '+' || keycode == '-')) + switch ( keycode ) { - return true; + // Accept +/- because they can be part of the number and space just + // because it's a convenient key to start editing with and is also + // consistent with many (all?) other editors, which allow starting + // editing using it. + case '+': + case '-': + case ' ': + return true; + + default: + return (keycode < 128) && wxIsdigit(keycode); } }