From 44a089b295c557c1ffbbae6fd3c36504140e92b0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 27 Jan 2018 15:49:46 +0100 Subject: [PATCH] Fix handling TAB in wxSearchCtrl in wxMSW Check whether wxTextCtrl has focus using Win32 ::GetFocus() instead of by comparing FindFocus() with "this" pointer, as the latter fails when wxTextCtrl is part of a composite control, such as wxSearchCtrl. This is enough to make pressing TAB in wxSearchCtrl correctly go to the next control instead of just beeping. Note that we could also use DoFindFocus() here, but this would be needlessly less efficient as we don't really need to find wxWindow corresponding to the focused HWND, as that function does. But we can't use HasFocus() here as it wouldn't work correctly here when the focus is on another sub-window of a composite control also containing this wxTextCtrl. --- src/msw/textctrl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 2f7bc4d21a..686435b620 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -2078,7 +2078,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) // forces at the moment unfortunately if ( !(m_windowStyle & wxTE_PROCESS_TAB)) { - if ( FindFocus() == this ) + if ( ::GetFocus() == GetHwnd() ) { int flags = 0; if (!event.ShiftDown())