extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll;
+static bool g_hasDoubleClicked = FALSE;
+
//-----------------------------------------------------------------------------
-// "button_press_event"
+// "button_release_event"
//-----------------------------------------------------------------------------
+/* we would normally emit a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event once
+ a GDK_2BUTTON_PRESS occurs, but this has the particular problem of the
+ listbox keeping the focus until it receives a GDK_BUTTON_RELEASE event.
+ this can lead to race conditions so that we emit the dclick event
+ after the GDK_BUTTON_RELEASE event after the GDK_2BUTTON_PRESS event */
+
static gint
-gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxListBox *listbox )
+gtk_listbox_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxListBox *listbox )
{
if (g_isIdle) wxapp_install_idle_handler();
if (!listbox->m_hasVMT) return FALSE;
- int sel = listbox->GetIndex( widget );
+ if (!g_hasDoubleClicked) return FALSE;
- if ((listbox->m_hasCheckBoxes) && (gdk_event->x < 15) && (gdk_event->type != GDK_2BUTTON_PRESS))
- {
- wxCheckListBox *clb = (wxCheckListBox *)listbox;
-
- clb->Check( sel, !clb->IsChecked(sel) );
-
- wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() );
- event.SetEventObject( listbox );
- event.SetInt( sel );
- listbox->GetEventHandler()->ProcessEvent( event );
- }
-
- if (gdk_event->type == GDK_2BUTTON_PRESS)
- {
wxCommandEvent event( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, listbox->GetId() );
event.SetEventObject( listbox );
listbox->GetEventHandler()->ProcessEvent( event );
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------------
+// "button_press_event"
+//-----------------------------------------------------------------------------
+
+static gint
+gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxListBox *listbox )
+{
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ if (g_blockEventsOnDrag) return FALSE;
+ if (g_blockEventsOnScroll) return FALSE;
+
+ if (!listbox->m_hasVMT) return FALSE;
+
+ int sel = listbox->GetIndex( widget );
+
+ if ((listbox->m_hasCheckBoxes) && (gdk_event->x < 15) && (gdk_event->type != GDK_2BUTTON_PRESS))
+ {
+ wxCheckListBox *clb = (wxCheckListBox *)listbox;
+
+ clb->Check( sel, !clb->IsChecked(sel) );
+
+ wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() );
+ event.SetEventObject( listbox );
+ event.SetInt( sel );
+ listbox->GetEventHandler()->ProcessEvent( event );
}
+
+ /* emit wxEVT_COMMAND_LISTBOX_DOUBLECLICKED later */
+ g_hasDoubleClicked = (gdk_event->type == GDK_2BUTTON_PRESS);
return FALSE;
}
(GtkSignalFunc)gtk_listbox_button_press_callback,
(gpointer) this );
+ gtk_signal_connect_after( GTK_OBJECT(list_item),
+ "button_release_event",
+ (GtkSignalFunc)gtk_listbox_button_release_callback,
+ (gpointer) this );
+
if (m_hasCheckBoxes)
{
gtk_signal_connect( GTK_OBJECT(list_item),
if (GTK_WIDGET_REALIZED (myfixed) && !GTK_WIDGET_REALIZED (widget))
gtk_widget_realize (widget);
- if (GTK_WIDGET_MAPPED (myfixed) && !GTK_WIDGET_MAPPED (widget))
+ if (GTK_WIDGET_MAPPED (myfixed) && !GTK_WIDGET_MAPPED (widget) && GTK_WIDGET_VISIBLE (widget))
gtk_widget_map (widget);
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (myfixed))
extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll;
+static bool g_hasDoubleClicked = FALSE;
+
//-----------------------------------------------------------------------------
-// "button_press_event"
+// "button_release_event"
//-----------------------------------------------------------------------------
+/* we would normally emit a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event once
+ a GDK_2BUTTON_PRESS occurs, but this has the particular problem of the
+ listbox keeping the focus until it receives a GDK_BUTTON_RELEASE event.
+ this can lead to race conditions so that we emit the dclick event
+ after the GDK_BUTTON_RELEASE event after the GDK_2BUTTON_PRESS event */
+
static gint
-gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxListBox *listbox )
+gtk_listbox_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxListBox *listbox )
{
if (g_isIdle) wxapp_install_idle_handler();
if (!listbox->m_hasVMT) return FALSE;
- int sel = listbox->GetIndex( widget );
+ if (!g_hasDoubleClicked) return FALSE;
- if ((listbox->m_hasCheckBoxes) && (gdk_event->x < 15) && (gdk_event->type != GDK_2BUTTON_PRESS))
- {
- wxCheckListBox *clb = (wxCheckListBox *)listbox;
-
- clb->Check( sel, !clb->IsChecked(sel) );
-
- wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() );
- event.SetEventObject( listbox );
- event.SetInt( sel );
- listbox->GetEventHandler()->ProcessEvent( event );
- }
-
- if (gdk_event->type == GDK_2BUTTON_PRESS)
- {
wxCommandEvent event( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, listbox->GetId() );
event.SetEventObject( listbox );
listbox->GetEventHandler()->ProcessEvent( event );
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------------
+// "button_press_event"
+//-----------------------------------------------------------------------------
+
+static gint
+gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxListBox *listbox )
+{
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ if (g_blockEventsOnDrag) return FALSE;
+ if (g_blockEventsOnScroll) return FALSE;
+
+ if (!listbox->m_hasVMT) return FALSE;
+
+ int sel = listbox->GetIndex( widget );
+
+ if ((listbox->m_hasCheckBoxes) && (gdk_event->x < 15) && (gdk_event->type != GDK_2BUTTON_PRESS))
+ {
+ wxCheckListBox *clb = (wxCheckListBox *)listbox;
+
+ clb->Check( sel, !clb->IsChecked(sel) );
+
+ wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() );
+ event.SetEventObject( listbox );
+ event.SetInt( sel );
+ listbox->GetEventHandler()->ProcessEvent( event );
}
+
+ /* emit wxEVT_COMMAND_LISTBOX_DOUBLECLICKED later */
+ g_hasDoubleClicked = (gdk_event->type == GDK_2BUTTON_PRESS);
return FALSE;
}
(GtkSignalFunc)gtk_listbox_button_press_callback,
(gpointer) this );
+ gtk_signal_connect_after( GTK_OBJECT(list_item),
+ "button_release_event",
+ (GtkSignalFunc)gtk_listbox_button_release_callback,
+ (gpointer) this );
+
if (m_hasCheckBoxes)
{
gtk_signal_connect( GTK_OBJECT(list_item),
if (GTK_WIDGET_REALIZED (myfixed) && !GTK_WIDGET_REALIZED (widget))
gtk_widget_realize (widget);
- if (GTK_WIDGET_MAPPED (myfixed) && !GTK_WIDGET_MAPPED (widget))
+ if (GTK_WIDGET_MAPPED (myfixed) && !GTK_WIDGET_MAPPED (widget) && GTK_WIDGET_VISIBLE (widget))
gtk_widget_map (widget);
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (myfixed))