From 0cf78ca14b6485f858e05a30a525f9d9c388854c Mon Sep 17 00:00:00 2001 From: Christiaan Bloemendaal Date: Mon, 13 Nov 2023 13:04:57 +0100 Subject: [PATCH] fix: handle keyboard selection --- CHANGELOG.MD | 4 ++++ Scripts/Editor/Browser/BrowserTreeView.cs | 17 +++++++++++++++-- package.json | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 7bc3707..d4f460c 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.2.1] +### Fixed +- Update active editor when selecting a new item with the keyboard + ## [2.2.0] ### Added diff --git a/Scripts/Editor/Browser/BrowserTreeView.cs b/Scripts/Editor/Browser/BrowserTreeView.cs index 3b9fa38..3b158d4 100644 --- a/Scripts/Editor/Browser/BrowserTreeView.cs +++ b/Scripts/Editor/Browser/BrowserTreeView.cs @@ -1,4 +1,5 @@ -using UnityEditor; +using System.Collections.Generic; +using UnityEditor; using UnityEditor.IMGUI.Controls; using UnityEngine; @@ -30,7 +31,6 @@ public BrowserTreeView(TreeViewState state, MultiColumnHeader multiColumnHeader) private void Initialize() { showAlternatingRowBackgrounds = true; - // showBorder = true; Reload(); } @@ -71,6 +71,19 @@ protected override bool CanMultiSelect(TreeViewItem item) return false; } + protected override void SelectionChanged(IList selectedIds) + { + if (selectedIds.Count != 1) + return; + + TreeViewItem item = FindItem(selectedIds[0], rootItem); + + if (item is BrowserTreeViewItem treeViewItem) + { + ItemClicked?.Invoke(treeViewItem); + } + } + protected override void SingleClickedItem(int id) { TreeViewItem item = FindItem(id, rootItem); diff --git a/package.json b/package.json index 0464f8c..e21352a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.brunomikoski.scriptableobjectcollection", "displayName": "Scriptable Object Collection", - "version": "2.2.0", + "version": "2.2.1", "unity": "2021.2", "description": "A library to help improve the usability of Unity3D Scriptable Objects by grouping them into a collection and exposing them by code or nice inspectors!", "keywords": [