From c667b518d178f6e4df3ac9cfe2a1e600a68fcc3b Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sun, 13 Aug 2006 01:22:37 +0000
Subject: [PATCH] fixes for several fatal problems when using wxComboCtrl as
 popup (patch 1539124)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40589 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 src/common/combocmn.cpp | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp
index b5cd42e424..fbad327842 100644
--- a/src/common/combocmn.cpp
+++ b/src/common/combocmn.cpp
@@ -191,7 +191,7 @@ void wxComboFrameEventHandler::OnIdle( wxIdleEvent& event )
 {
     wxWindow* winFocused = ::wxWindow::FindFocus();
 
-    wxWindow* popup = m_combo->GetPopupControl();
+    wxWindow* popup = m_combo->GetPopupControl()->GetControl();
     wxWindow* winpopup = m_combo->GetPopupWindow();
 
     if (
@@ -1342,6 +1342,15 @@ bool wxComboCtrlBase::PreprocessMouseEvent( wxMouseEvent& event,
     wxLongLong t = ::wxGetLocalTimeMillis();
     int evtType = event.GetEventType();
 
+#if !USE_TRANSIENT_POPUP
+    if ( m_isPopupShown &&
+         ( evtType == wxEVT_LEFT_DOWN || evtType == wxEVT_RIGHT_DOWN ) )
+    {
+        HidePopup();
+        return true;
+    }
+#endif
+
     //
     // Generate our own double-clicks
     // (to allow on-focus dc-event on double-clicks instead of triple-clicks)
@@ -1541,13 +1550,13 @@ void wxComboCtrlBase::CreatePopup()
 // Destroy popup window and the child control
 void wxComboCtrlBase::DestroyPopup()
 {
+    HidePopup();
+
     if ( m_popup )
         m_popup->RemoveEventHandler(m_popupExtraHandler);
 
     delete m_popupExtraHandler;
 
-    HidePopup();
-
     delete m_popupInterface;
 
     if ( m_winPopup )
-- 
2.47.2