From ac22ab9aabaa7d7fca65db3ad9f56be0451c570e Mon Sep 17 00:00:00 2001 From: handama <55939089+handama@users.noreply.github.com> Date: Tue, 31 Dec 2024 09:17:23 +0800 Subject: [PATCH] fix a bug of treeview control that it'll select first top visible item unintentionally (#131) * deselect from treeview control would cause 'selected owner house' changed to the top one by accident * now deselection will reset selection to parent node --- MissionEditor/IsoView.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MissionEditor/IsoView.cpp b/MissionEditor/IsoView.cpp index 870b414..a6978b6 100644 --- a/MissionEditor/IsoView.cpp +++ b/MissionEditor/IsoView.cpp @@ -2137,10 +2137,12 @@ void CIsoView::OnRButtonUp(UINT nFlags, CPoint point) if (!ignoreClick) { AD.reset(); - - CMyViewFrame& frame = *((CMyViewFrame*)owner); - frame.m_objectview->GetTreeCtrl().Select(NULL, TVGN_CARET); } + + CTreeCtrl& treeCtrl = ((CMyViewFrame*)owner)->m_objectview->GetTreeCtrl(); + HTREEITEM hParentItem = treeCtrl.GetParentItem(treeCtrl.GetSelectedItem()); + treeCtrl.Select(hParentItem, TVGN_CARET); + return; }