From e911dd0a5abd10c32d6cce4cff44e1cb06c3036b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 5 Apr 2012 18:40:20 +0000 Subject: [PATCH] Hide combobox popup when it is hidden itself in wxMSW. It was possible to hide the main part of a combobox control but keep its popup shown and this notably happened in wxGrid when TAB was pressed while a wxChoice cell editor was dropped down. Avoid this Cheshire combobox syndrome by explicitly dismissing the popup when a combobox is hidden. Closes #3113. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71104 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/choice.h | 2 ++ src/msw/choice.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/wx/msw/choice.h b/include/wx/msw/choice.h index ec7d272651..d17e1c655d 100644 --- a/include/wx/msw/choice.h +++ b/include/wx/msw/choice.h @@ -66,6 +66,8 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxChoiceNameStr); + virtual bool Show(bool show = true); + virtual void SetLabel(const wxString& label); virtual unsigned int GetCount() const; diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index 650dff48ce..0c0dbc10c7 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -646,6 +646,19 @@ void wxChoice::MSWDoPopupOrDismiss(bool show) ::SendMessage(GetHwnd(), CB_SHOWDROPDOWN, show, 0); } +bool wxChoice::Show(bool show) +{ + if ( !wxChoiceBase::Show(show) ) + return false; + + // When hiding the combobox, we also need to hide its popup part as it + // doesn't happen automatically. + if ( !show && ::SendMessage(GetHwnd(), CB_GETDROPPEDSTATE, 0, 0) ) + MSWDoPopupOrDismiss(false); + + return true; +} + // ---------------------------------------------------------------------------- // MSW message handlers // ---------------------------------------------------------------------------- -- 2.45.2