]> git.saurik.com Git - wxWidgets.git/commitdiff
Make wxTransientPopupWindow ignore button down events
authorRobert Roebling <robert@roebling.de>
Mon, 27 Feb 2006 09:16:28 +0000 (09:16 +0000)
committerRobert Roebling <robert@roebling.de>
Mon, 27 Feb 2006 09:16:28 +0000 (09:16 +0000)
    which have been sent before or at the same time as
    the control creation time so that these evens don't
    make the control disappear again.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37747 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/popupwin.h
src/gtk/popupwin.cpp

index b35eb730046b3e285219e989506bc4177950a8d9..b32e4684b5c37f7c09576180de2da1e716e531de 100644 (file)
@@ -35,6 +35,9 @@ public:
     // --------------
 
     virtual void OnInternalIdle();
+    
+    // GTK time when connecting to button_press signal
+    wxUint32  m_time;
 
 
 protected:
index 0676e6e6393b2f42828e0d44f07504d294ec2454..91ed9b009b0a7011ea81b6e4ad016a652551d9d4 100644 (file)
@@ -39,13 +39,16 @@ static gint gtk_popup_button_press (GtkWidget *widget, GdkEvent *gdk_event, wxPo
 {
     GtkWidget *child = gtk_get_event_widget (gdk_event);
 
-  /* We don't ask for button press events on the grab widget, so
-   *  if an event is reported directly to the grab widget, it must
-   *  be on a window outside the application (and thus we remove
-   *  the popup window). Otherwise, we check if the widget is a child
-   *  of the grab widget, and only remove the popup window if it
-   *  is not.
-   */
+    /* Ignore events sent out before we connected to the signal */
+    if (win->m_time >= ((GdkEventButton*)gdk_event)->time)
+        return FALSE;
+
+    /*  We don't ask for button press events on the grab widget, so
+     *  if an event is reported directly to the grab widget, it must
+     *  be on a window outside the application (and thus we remove
+     *  the popup window). Otherwise, we check if the widget is a child
+     *  of the grab widget, and only remove the popup window if it
+     *  is not. */
     if (child != widget)
     {
         while (child)
@@ -75,7 +78,7 @@ static gint gtk_dialog_focus_callback( GtkWidget *widget, GtkDirectionType WXUNU
     if (g_isIdle)
         wxapp_install_idle_handler();
 
-    // This disables GTK's tab traversal
+    /* This disables GTK's tab traversal */
     g_signal_stop_emission_by_name (widget, "focus");
     return TRUE;
 }
@@ -214,6 +217,8 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
     g_signal_connect (m_widget, "focus",
                       G_CALLBACK (gtk_dialog_focus_callback), this);
 
+    m_time = gtk_get_current_event_time();
+
     g_signal_connect (m_widget, "button_press_event",
                       G_CALLBACK (gtk_popup_button_press), this);