Fix dismissing wxComboCtrl popup

When wxComboCtrl popup window is dismissed we need to hide it but calling ShowWindow() Win API directly from WM_ACTIVATE event handler causes some side effects like calling the handler again (under Win 7) or setting the focus improperly (under Win 10). To avoid these problems we should postpone hiding.

Closes #18376.
This commit is contained in:
Artur Wieczorek 2019-08-17 21:51:30 +02:00
parent bcca16911d
commit 881aabf63e

View File

@ -549,6 +549,9 @@ public:
#endif
private:
#if USES_GENERICTLW
void HideOnDeactivate();
#endif // USES_GENERICTLW
wxComboCtrlBase* m_combo;
wxDECLARE_EVENT_TABLE();
@ -586,11 +589,23 @@ void wxComboPopupWindowEvtHandler::OnActivate( wxActivateEvent& event )
if ( !event.GetActive() )
{
// Tell combo control that we are dismissed.
m_combo->HidePopup(true);
#ifdef __WXMSW__
// We need to hide the popup but calling ::ShowWindow() directly from WM_ACTIVATE
// event handler causes some side effects like calling this handler again (Win 7)
// or setting the focus improperly (Win 10), so postpone it slightly.
// See wxPopupTransientWindow::MSWHandleMessage().
CallAfter(&wxComboPopupWindowEvtHandler::HideOnDeactivate);
#else
HideOnDeactivate();
#endif __WXMSW__ / !__WXMSW__
event.Skip();
}
}
void wxComboPopupWindowEvtHandler::HideOnDeactivate()
{
m_combo->HidePopup(true);
}
#endif