From 2c2cf587b46b1a6121358d5949963c23e6a094f6 Mon Sep 17 00:00:00 2001 From: David Bailes Date: Tue, 11 Jun 2019 14:38:34 +0100 Subject: [PATCH] Bug 496 - NumericTextCtrls shouldn't accept numbers when any modifier keys are pressed Problem: NumericTextCtrls act on numeric keys, even when modifier keys are pressed. This shouldn't be the case, and has the knock on effect that shortcuts like ctrl + 1, don't work when a NumericTextCtrl is the focus. Fix: Check that there are no modifier keys pressed. --- src/widgets/NumericTextCtrl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widgets/NumericTextCtrl.cpp b/src/widgets/NumericTextCtrl.cpp index e881ba47c..c393cf127 100644 --- a/src/widgets/NumericTextCtrl.cpp +++ b/src/widgets/NumericTextCtrl.cpp @@ -1752,7 +1752,7 @@ void NumericTextCtrl::OnCaptureKey(wxCommandEvent &event) return; default: - if (keyCode >= '0' && keyCode <= '9') + if (keyCode >= '0' && keyCode <= '9' && !kevent->HasAnyModifiers()) return; } @@ -1770,7 +1770,7 @@ void NumericTextCtrl::OnKeyUp(wxKeyEvent &event) if ((keyCode >= WXK_NUMPAD0) && (keyCode <= WXK_NUMPAD9)) keyCode -= WXK_NUMPAD0 - '0'; - if ((keyCode >= '0' && keyCode <= '9') || + if ((keyCode >= '0' && keyCode <= '9' && !event.HasAnyModifiers()) || (keyCode == WXK_DELETE) || (keyCode == WXK_BACK) || (keyCode == WXK_UP) || @@ -1801,7 +1801,7 @@ void NumericTextCtrl::OnKeyDown(wxKeyEvent &event) if ((keyCode >= WXK_NUMPAD0) && (keyCode <= WXK_NUMPAD9)) keyCode -= WXK_NUMPAD0 - '0'; - if (!mReadOnly && (keyCode >= '0' && keyCode <= '9')) { + if (!mReadOnly && (keyCode >= '0' && keyCode <= '9' && !event.HasAnyModifiers())) { int digitPosition = mDigits[mFocusedDigit].pos; if (mValueString[digitPosition] == wxChar('-')) { mValue = std::max(mMinValue, std::min(mMaxValue, 0.0));