From c43e0fa123a47cf4f5d79e88336544d6fc5de399 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 14 Jul 2019 01:40:13 +0200 Subject: [PATCH] Move WM_CHAR handling inside the switch in wxTextCtrl code No real changes, just check for WM_CHAR inside the existing "switch" instead of writing a separate "if" statement just for it. Note that removing HasFlag(wxTE_PROCESS_ENTER) test shouldn't matter as we should be only getting WM_CHAR for VK_RETURN when this flag is used. --- src/msw/textctrl.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 80eec63138..678a04b09c 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -2178,27 +2178,26 @@ wxTextCtrl::MSWHandleMessage(WXLRESULT *rc, { bool processed = wxTextCtrlBase::MSWHandleMessage(rc, nMsg, wParam, lParam); - // Handle the special case of "Enter" key: the user code needs to specify - // wxTE_PROCESS_ENTER style to get it in the first place, but if this flag - // is used, then even if the wxEVT_TEXT_ENTER handler skips the event, the - // normal action of this key is not performed because IsDialogMessage() is - // not called and, also, an annoying beep is generated by EDIT default - // WndProc. - // - // Fix these problems by explicitly performing the default function of this - // key (which would be done by MSWProcessMessage() if we didn't have - // wxTE_PROCESS_ENTER) and preventing the default WndProc from getting it. - if ( nMsg == WM_CHAR && - !processed && - HasFlag(wxTE_PROCESS_ENTER) && - wParam == VK_RETURN ) - { - if ( ClickDefaultButtonIfPossible() ) - processed = true; - } - switch ( nMsg ) { + case WM_CHAR: + // Handle the special case of "Enter" key: the user code needs to specify + // wxTE_PROCESS_ENTER style to get it in the first place, but if this flag + // is used, then even if the wxEVT_TEXT_ENTER handler skips the event, the + // normal action of this key is not performed because IsDialogMessage() is + // not called and, also, an annoying beep is generated by EDIT default + // WndProc. + // + // Fix these problems by explicitly performing the default function of this + // key (which would be done by MSWProcessMessage() if we didn't have + // wxTE_PROCESS_ENTER) and preventing the default WndProc from getting it. + if ( !processed && wParam == VK_RETURN ) + { + if ( ClickDefaultButtonIfPossible() ) + processed = true; + } + break; + case WM_GETDLGCODE: { // Ensure that the result value is initialized even if the base