]> git.saurik.com Git - wxWidgets.git/commitdiff
Update controls sample to follow documented logic
authorRobert Roebling <robert@roebling.de>
Fri, 23 May 2008 11:04:37 +0000 (11:04 +0000)
committerRobert Roebling <robert@roebling.de>
Fri, 23 May 2008 11:04:37 +0000 (11:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53720 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/controls/controls.cpp

index 0b9b11546dc7e46dddf51e40c0e2ac8a27084a34..6cd37657df4a8d90f50db439f1f2ee14ea6871cd 100644 (file)
@@ -1191,22 +1191,24 @@ void MyPanel::OnChangeColour(wxCommandEvent& WXUNUSED(event))
 
 void MyPanel::OnListBox( wxCommandEvent &event )
 {
 
 void MyPanel::OnListBox( wxCommandEvent &event )
 {
-    if (event.GetInt() == -1)
-    {
-        m_text->AppendText( _T("ListBox has no selections anymore\n") );
-        return;
-    }
-
     wxListBox *listbox = event.GetId() == ID_LISTBOX ? m_listbox
                                                      : m_listboxSorted;
 
     wxListBox *listbox = event.GetId() == ID_LISTBOX ? m_listbox
                                                      : m_listboxSorted;
 
+    bool deselect = false;
+    if (listbox->HasFlag(wxLB_MULTIPLE) || listbox->HasFlag(wxLB_EXTENDED))
+    {
+        deselect = !event.IsSelection();
+        if (deselect)
+            m_text->AppendText( _T("ListBox deselection event\n") );
+    }
+
     m_text->AppendText( _T("ListBox event selection string is: '") );
     m_text->AppendText( event.GetString() );
     m_text->AppendText( _T("'\n") );
 
     // can't use GetStringSelection() with multiple selections, there could be
     // more than one of them
     m_text->AppendText( _T("ListBox event selection string is: '") );
     m_text->AppendText( event.GetString() );
     m_text->AppendText( _T("'\n") );
 
     // can't use GetStringSelection() with multiple selections, there could be
     // more than one of them
-    if ( !listbox->HasFlag(wxLB_MULTIPLE) )
+    if ( !listbox->HasFlag(wxLB_MULTIPLE) && !listbox->HasFlag(wxLB_EXTENDED) )
     {
         m_text->AppendText( _T("ListBox control selection string is: '") );
         m_text->AppendText( listbox->GetStringSelection() );
     {
         m_text->AppendText( _T("ListBox control selection string is: '") );
         m_text->AppendText( listbox->GetStringSelection() );