From 9a49e0c42f3884f7d221fdca0c97f7913d6233f0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 16 Nov 2013 23:41:16 +0000 Subject: [PATCH] Don't eat TAB presses for wxComboBox with wxTE_PROCESS_ENTER in wxMSW. Still allow to use TAB for navigation even when a wxComboBox has wxTE_PROCESS_ENTER style. Use the same hack for wxTextCtrl, i.e. implement the navigation ourselves as we can't let IsDialogMessage() handle it but still get VK_ENTER key presses. Closes #12808. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@75216 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/combobox.cpp | 67 ++++++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index c4f0cb36b0..692c546654 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -228,36 +228,55 @@ bool wxComboBox::MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam) case WM_CHAR: // for compatibility with wxTextCtrl, generate a special message // when Enter is pressed - if ( wParam == VK_RETURN ) + switch ( wParam ) { - if (SendMessage(GetHwnd(), CB_GETDROPPEDSTATE, 0, 0)) - return false; + case VK_RETURN: + { + if (SendMessage(GetHwnd(), CB_GETDROPPEDSTATE, 0, 0)) + return false; - wxCommandEvent event(wxEVT_TEXT_ENTER, m_windowId); + wxCommandEvent event(wxEVT_TEXT_ENTER, m_windowId); - const int sel = GetSelection(); - event.SetInt(sel); - event.SetString(GetValue()); - InitCommandEventWithItems(event, sel); + const int sel = GetSelection(); + event.SetInt(sel); + event.SetString(GetValue()); + InitCommandEventWithItems(event, sel); - if ( ProcessCommand(event) ) - { - // don't let the event through to the native control - // because it doesn't need it and may generate an annoying - // beep if it gets it - return true; - } + if ( ProcessCommand(event) ) + { + // don't let the event through to the native control + // because it doesn't need it and may generate an annoying + // beep if it gets it + return true; + } + } + break; + + case VK_TAB: + // If we have wxTE_PROCESS_ENTER style, we get all char + // events, including those for TAB which are usually used + // for keyboard navigation, but we should not process them + // unless we also have wxTE_PROCESS_TAB style. + if ( !HasFlag(wxTE_PROCESS_TAB) ) + { + int flags = 0; + if ( !wxIsShiftDown() ) + flags |= wxNavigationKeyEvent::IsForward; + if ( wxIsCtrlDown() ) + flags |= wxNavigationKeyEvent::WinChange; + if ( Navigate(flags) ) + return true; + } + break; } - // fall through, WM_CHAR is one of the message we should forward. + } - default: - if ( ShouldForwardFromEditToCombo(msg) ) - { - // For all the messages forward from the edit control the - // result is not used. - WXLRESULT result; - return MSWHandleMessage(&result, msg, wParam, lParam); - } + if ( ShouldForwardFromEditToCombo(msg) ) + { + // For all the messages forward from the edit control the + // result is not used. + WXLRESULT result; + return MSWHandleMessage(&result, msg, wParam, lParam); } return false;