fix clicking a treeview element tripping expand/collapse

set the wasselected check earlier in the test chain, and test against it  so just selecting it doesn't automatically also trip expand/collapse
This commit is contained in:
AzaezelX 2026-01-20 11:56:44 -06:00
parent 475142b847
commit 89fb2990df

View file

@ -3389,7 +3389,7 @@ void GuiTreeViewCtrl::onMouseDown(const GuiEvent & event)
mPossibleRenameItem = NULL; mPossibleRenameItem = NULL;
mRenamingItem = NULL; mRenamingItem = NULL;
mTempItem = NULL; mTempItem = NULL;
bool wasSelected = isSelected(item);
// //
if( event.modifier & SI_MULTISELECT ) if( event.modifier & SI_MULTISELECT )
{ {
@ -3473,8 +3473,7 @@ void GuiTreeViewCtrl::onMouseDown(const GuiEvent & event)
else if ( !hitFlags.test(OnImage) ) else if ( !hitFlags.test(OnImage) )
{ {
mTempItem = item; mTempItem = item;
bool wasSelected = isSelected( item );
bool multiSelect = getSelectedItemsCount() > 1; bool multiSelect = getSelectedItemsCount() > 1;
if( !wasSelected || !multiSelect ) if( !wasSelected || !multiSelect )
@ -3520,7 +3519,7 @@ void GuiTreeViewCtrl::onMouseDown(const GuiEvent & event)
return; return;
// //
if ( mFullRowSelect || hitFlags.test( OnImage ) ) if ((mFullRowSelect || hitFlags.test(OnImage)) && wasSelected)
{ {
item->setExpanded(!item->isExpanded()); item->setExpanded(!item->isExpanded());
if( !item->isInspectorData() && item->mState.test(Item::VirtualParent) ) if( !item->isInspectorData() && item->mState.test(Item::VirtualParent) )