- wxNavigationKeyEvent new_event;
- /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
- new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
- /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
- new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
- new_event.SetCurrentFocus( listbox );
- ret = listbox->GetEventHandler()->ProcessEvent( new_event );
- }
-
- if ((gdk_event->keyval == GDK_Return) && (!ret))
- {
- // eat return in all modes
- ret = TRUE;
- }
-
-#if wxUSE_CHECKLISTBOX
- if ((gdk_event->keyval == ' ') && (listbox->m_hasCheckBoxes) && (!ret))
- {
- int sel = listbox->GtkGetIndex( widget );
-
- wxCheckListBox *clb = (wxCheckListBox *)listbox;
-
- clb->Check( sel, !clb->IsChecked(sel) );
-
- wxCommandEvent new_event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() );
- new_event.SetEventObject( listbox );
- new_event.SetInt( sel );
- ret = listbox->GetEventHandler()->ProcessEvent( new_event );
- }
-#endif // wxUSE_CHECKLISTBOX
-
- if (ret)
- {
- gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
- return TRUE;
+ int index = -1;
+ if (!listbox->HasMultipleSelection())
+ index = listbox->GetSelection();
+ else
+ {
+ wxArrayInt sels;
+ if (listbox->GetSelections( sels ) < 1)
+ return FALSE;
+ index = sels[0];
+ }
+
+ if (index != wxNOT_FOUND)
+ {
+ wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, listbox->GetId() );
+ event.SetEventObject( listbox );
+
+ GtkTreeEntry* entry = listbox->GtkGetEntry( index );
+
+ // indicate that this is a selection
+ event.SetExtraLong( 1 );
+
+ event.SetInt( index );
+ event.SetString(wxConvUTF8.cMB2WX(gtk_tree_entry_get_label(entry)));
+
+ if ( listbox->HasClientObjectData() )
+ event.SetClientObject(
+ (wxClientData*) gtk_tree_entry_get_userdata(entry)
+ );
+ else if ( listbox->HasClientUntypedData() )
+ event.SetClientData( gtk_tree_entry_get_userdata(entry) );
+
+ /* bool ret = */ listbox->HandleWindowEvent( event );
+
+ g_object_unref (entry);
+
+// wxMac and wxMSW always invoke default action
+// if (!ret)
+ {
+ // DClick not handled -> invoke default action
+ wxWindow *tlw = wxGetTopLevelParent( listbox );
+ if (tlw)
+ {
+ GtkWindow *gtk_window = GTK_WINDOW( tlw->GetHandle() );
+ if (gtk_window)
+ gtk_window_activate_default( gtk_window );
+ }
+ }
+
+ // Always intercept, otherwise we'd get another dclick
+ // event from row_activated
+ return TRUE;
+ }