Fix wxListBox selection handling broken by r64500.

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
This commit is contained in:
Václav Slavík 2010-08-25 15:02:30 +00:00
parent a6856aa899
commit a614ffae71
2 changed files with 8 additions and 1 deletions

View 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:

View 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)