Fix: UI: Extend select for tree-view not always working

Noticed that when clicking a tree-view item with multi-select support
(shape keys in this case) twice without ctrl held, and then another one
with ctrl held, the previous one would get deselected.

That's because the second click would first deselect all items and then
call `AbstractViewItem::activate()` on the clicked item. This would fail
to re-select the item, because it skipped touching selection when the
active state didn't change (as was the case here).
This commit is contained in:
Julian Eisel
2025-07-07 18:14:50 +02:00
parent 36d7925a72
commit db115c6e4f
2 changed files with 6 additions and 0 deletions

View File

@@ -302,6 +302,8 @@ class AbstractViewItem {
* click), not if the view reflects an external change (e.g.
* #AbstractViewItem::should_be_active() changes from returning false to returning true).
*
* Also ensures the item is selected if it's active.
*
* Requires the view to have completed reconstruction, see #is_reconstructed(). Otherwise the
* actual item state is unknown, possibly calling state-change update functions incorrectly.
*/

View File

@@ -72,6 +72,10 @@ void AbstractViewItem::activate(bContext &C)
{
if (set_state_active()) {
on_activate(C);
}
/* Make sure active item is selected. */
if (is_active()) {
set_selected(true);
}
}