Fix missing deselection of single selected but not focused item
A generic multi-select wxListCtrl did not deselect a single selected
item that did not have focus when the user single-selected another
item.
This fixes a regression introduced in fedc80eee3 (Improve selection and
focus events generation in wxGenericLisCtrl, 2020-10-10).
Closes #24312.
This commit is contained in:
parent
f24b3d5483
commit
d091a44adb
2 changed files with 32 additions and 1 deletions
|
|
@ -2220,7 +2220,7 @@ void wxListMainWindow::HighlightOnly( size_t line, size_t oldLine )
|
|||
: RefreshLine(oldLine); // refresh the old focus to remove it
|
||||
}
|
||||
|
||||
if ( selCount > 1 ) // multiple-selection only
|
||||
if ( selCount >= 1 ) // multiple-selection only
|
||||
{
|
||||
// Deselecting many items at once will generate wxEVT_XXX_DESELECTED event
|
||||
// for each one of them. although this may be inefficient if the number of
|
||||
|
|
|
|||
|
|
@ -273,6 +273,37 @@ void ListBaseTestCase::MultiSelect()
|
|||
CPPUNIT_ASSERT_EQUAL(1, focused.GetCount()); // because the focus changed from item 0 to anchor
|
||||
CPPUNIT_ASSERT_EQUAL(0, selected.GetCount()); // anchor is already in selection state
|
||||
CPPUNIT_ASSERT_EQUAL(2, deselected.GetCount()); // items 0 and 1 are deselected
|
||||
|
||||
focused.Clear();
|
||||
selected.Clear();
|
||||
deselected.Clear();
|
||||
|
||||
list->GetItemRect(3, pos);
|
||||
point = list->ClientToScreen(pos.GetPosition()) + wxPoint(10, 10);
|
||||
|
||||
// select and deselect item 3 while leaving item 2 selected
|
||||
for ( int i = 0; i < 2; ++i )
|
||||
{
|
||||
sim.MouseMove(point + wxPoint(i*10, 0));
|
||||
wxYield();
|
||||
|
||||
sim.KeyDown(WXK_CONTROL);
|
||||
sim.MouseClick();
|
||||
sim.KeyUp(WXK_CONTROL);
|
||||
wxYield();
|
||||
}
|
||||
|
||||
// select only item 3
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, list->GetSelectedItemCount()); // item 3 is the only selected item
|
||||
CPPUNIT_ASSERT_EQUAL(1, focused.GetCount()); // because the focus changed from anchor to item 3
|
||||
CPPUNIT_ASSERT_EQUAL(2, selected.GetCount()); // item 3 was selected twice
|
||||
CPPUNIT_ASSERT_EQUAL(2, deselected.GetCount()); // anchor and item 3 were each deselected once
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue