+//-----------------------------------------------------------------------------
+// "button_press"
+//-----------------------------------------------------------------------------
+
+extern "C" {
+static gint gtk_popup_button_press (GtkWidget *widget, GdkEvent *gdk_event, wxPopupWindow* win )
+{
+ 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.
+ */
+ if (child != widget)
+ {
+ while (child)
+ {
+ if (child == widget)
+ return FALSE;
+ child = child->parent;
+ }
+ }
+
+ wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() );
+ event.SetEventObject( win );
+
+ (void)win->HandleWindowEvent( event );
+
+ return TRUE;
+}
+}
+