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.
This commit is contained in:
Vadim Zeitlin
2020-06-20 19:52:43 +02:00
parent 6f36d2e2f8
commit 1208aa116a

View File

@@ -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);
}
}