]> git.saurik.com Git - wxWidgets.git/commitdiff
Better correction to the wxListBox misbehaviour.
authorRobert Roebling <robert@roebling.de>
Tue, 22 Feb 2005 22:45:32 +0000 (22:45 +0000)
committerRobert Roebling <robert@roebling.de>
Tue, 22 Feb 2005 22:45:32 +0000 (22:45 +0000)
   Strangely, the listbox sends out 2 events upon
   the first selection.

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

samples/controls/controls.cpp
src/gtk/listbox.cpp
src/gtk1/listbox.cpp

index 77fefdba72dc82096591a4c58d7f87045eb0d76d..aafd3d3b44f32d9301ddf9c120fc86a4725e8e2c 100644 (file)
@@ -677,7 +677,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
     wxPanel *panel = new wxPanel(m_book);
     m_listbox = new wxListBox( panel, ID_LISTBOX,
                                wxPoint(10,10), wxSize(120,70),
     wxPanel *panel = new wxPanel(m_book);
     m_listbox = new wxListBox( panel, ID_LISTBOX,
                                wxPoint(10,10), wxSize(120,70),
-                               5, choices, wxLB_MULTIPLE /*|wxLB_ALWAYS_SB*/ );
+                               5, choices, wxLB_MULTIPLE |wxLB_ALWAYS_SB );
     m_listboxSorted = new wxListBox( panel, ID_LISTBOX_SORTED,
                                      wxPoint(10,90), wxSize(120,70),
                                      5, choices, wxLB_SORT );
     m_listboxSorted = new wxListBox( panel, ID_LISTBOX_SORTED,
                                      wxPoint(10,90), wxSize(120,70),
                                      5, choices, wxLB_SORT );
index b71512c25085bee13244b1d67ac294540359257e..b522fd7a88bdc5c8586a4b37bea7683517175482 100644 (file)
@@ -233,18 +233,21 @@ gtk_listbox_button_press_callback( GtkWidget *widget,
     }
 #endif // wxUSE_CHECKLISTBOX
 
     }
 #endif // wxUSE_CHECKLISTBOX
 
-#if 0
     if ((gdk_event->state == 0) &&
          (((listbox->GetWindowStyleFlag() & wxLB_MULTIPLE) != 0) ||
           ((listbox->GetWindowStyleFlag() & wxLB_EXTENDED) != 0)) )
     {
     if ((gdk_event->state == 0) &&
          (((listbox->GetWindowStyleFlag() & wxLB_MULTIPLE) != 0) ||
           ((listbox->GetWindowStyleFlag() & wxLB_EXTENDED) != 0)) )
     {
-        if (listbox->IsSelected(sel))
-        {
-            gtk_list_unselect_item( GTK_LIST(listbox->m_list), sel );
-            return true;
-        }
+            listbox->m_blockEvent = TRUE;
+
+            int i;
+            for (i = 0; i < (int)listbox->GetCount(); i++)
+                if (i != sel)
+                    gtk_list_unselect_item( GTK_LIST(listbox->m_list), i );
+                
+            listbox->m_blockEvent = FALSE;
+            
+            return false;
     }
     }
-#endif
 
     /* emit wxEVT_COMMAND_LISTBOX_DOUBLECLICKED later */
     g_hasDoubleClicked = (gdk_event->type == GDK_2BUTTON_PRESS);
 
     /* emit wxEVT_COMMAND_LISTBOX_DOUBLECLICKED later */
     g_hasDoubleClicked = (gdk_event->type == GDK_2BUTTON_PRESS);
index b71512c25085bee13244b1d67ac294540359257e..b522fd7a88bdc5c8586a4b37bea7683517175482 100644 (file)
@@ -233,18 +233,21 @@ gtk_listbox_button_press_callback( GtkWidget *widget,
     }
 #endif // wxUSE_CHECKLISTBOX
 
     }
 #endif // wxUSE_CHECKLISTBOX
 
-#if 0
     if ((gdk_event->state == 0) &&
          (((listbox->GetWindowStyleFlag() & wxLB_MULTIPLE) != 0) ||
           ((listbox->GetWindowStyleFlag() & wxLB_EXTENDED) != 0)) )
     {
     if ((gdk_event->state == 0) &&
          (((listbox->GetWindowStyleFlag() & wxLB_MULTIPLE) != 0) ||
           ((listbox->GetWindowStyleFlag() & wxLB_EXTENDED) != 0)) )
     {
-        if (listbox->IsSelected(sel))
-        {
-            gtk_list_unselect_item( GTK_LIST(listbox->m_list), sel );
-            return true;
-        }
+            listbox->m_blockEvent = TRUE;
+
+            int i;
+            for (i = 0; i < (int)listbox->GetCount(); i++)
+                if (i != sel)
+                    gtk_list_unselect_item( GTK_LIST(listbox->m_list), i );
+                
+            listbox->m_blockEvent = FALSE;
+            
+            return false;
     }
     }
-#endif
 
     /* emit wxEVT_COMMAND_LISTBOX_DOUBLECLICKED later */
     g_hasDoubleClicked = (gdk_event->type == GDK_2BUTTON_PRESS);
 
     /* emit wxEVT_COMMAND_LISTBOX_DOUBLECLICKED later */
     g_hasDoubleClicked = (gdk_event->type == GDK_2BUTTON_PRESS);