]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix wxListBox selection handling broken by r64500.
authorVáclav Slavík <vslavik@fastmail.fm>
Wed, 25 Aug 2010 15:02:30 +0000 (15:02 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Wed, 25 Aug 2010 15:02:30 +0000 (15:02 +0000)
r64500 introduced tracking of previous selection in wxMSW's wxListBox so
that an event isn't sent when the user clicks already selected item
again. Unfortunately, it forgot to account for programatic changes of
selection (e.g. when all items are removed, so is the selection) and
didn't update selection book-keeping information in that case. The
result was that the event wasn't sent when it should be in some cases.

Fixed by using UpdateOldSelections() even in single-selection case in
wxMSW.

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

include/wx/listbox.h
src/common/lboxcmn.cpp

index 01f64a7ab1caea3bcfc78bb8d98a3085ab2169c2..d2332d5d132a011f3f51751712f46534229b3237 100644 (file)
@@ -122,7 +122,7 @@ protected:
     wxArrayInt m_oldSelections;
 
     // Update m_oldSelections with currently selected items (does nothing in
-    // single selection mode).
+    // single selection mode on platforms other than MSW).
     void UpdateOldSelections();
 
 private:
index f7d4fb91a8f7a91766c50765147b6bc93feccb7a..8787130451b1d615ddcc6cf04a15ff376dddfc09 100644 (file)
@@ -86,8 +86,15 @@ void wxListBoxBase::DeselectAll(int itemToLeaveSelected)
 
 void wxListBoxBase::UpdateOldSelections()
 {
+    // We need to remember the selection even in single-selection case on
+    // Windows, so that we don't send an event when the user clicks on an
+    // already selected item.
+#ifndef __WXMSW__
     if (HasFlag(wxLB_MULTIPLE) || HasFlag(wxLB_EXTENDED))
+#endif
+    {
         GetSelections( m_oldSelections );
+    }
 }
 
 bool wxListBoxBase::SendEvent(wxEventType evtType, int item, bool selected)