From 0c6d6e6472fa7663acb301b227b733faabcb6aaf Mon Sep 17 00:00:00 2001 From: Anton Triest Date: Mon, 16 Mar 2020 00:30:41 +0100 Subject: [PATCH] Fix deselecting items on branch toggle in wxTR_MULTIPLE control Don't deselect all the other items when an item is collapsed or expanded in wxGenericTreeCtrl with wxTR_MULTIPLE style, this was completely unexpected and seems to have been accidentally introduced back in 35cf1ec63c447856f09fc59bcf60f040f51f3aca Closes #18680. --- src/generic/treectlg.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 2473fb8c97..63acf179cc 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -3789,13 +3789,19 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) GetEventHandler()->ProcessEvent(nevent); } - // this facilitates multiple-item drag-and-drop - if ( HasFlag(wxTR_MULTIPLE) && !(event.CmdDown() || event.ShiftDown()) ) + // Don't deselect anything if we're just collapsing or expanding + // the item. + if ( !(flags & wxTREE_HITTEST_ONITEMBUTTON) ) { - wxArrayTreeItemIds selections; - if ( GetSelections(selections) > 1 ) + // this facilitates multiple-item drag-and-drop + if ( HasFlag(wxTR_MULTIPLE) && + !(event.CmdDown() || event.ShiftDown()) ) { - DoSelectItem(item, true, false); + wxArrayTreeItemIds selections; + if ( GetSelections(selections) > 1 ) + { + DoSelectItem(item, true, false); + } } }