From 6c1e380a3e005cb5fd7aec2b3d80e05434673c27 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Mon, 23 Jun 2025 17:24:53 +0200 Subject: [PATCH 1/3] fix search item hover auto focusing item Change what happens when search items get focused to prevent focus being taken away from search box. Also adds a highlight to mouse hovered search item. --- Source/Editor/Windows/Search/SearchItem.cs | 30 +++++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Source/Editor/Windows/Search/SearchItem.cs b/Source/Editor/Windows/Search/SearchItem.cs index 11bc79991..5336c2855 100644 --- a/Source/Editor/Windows/Search/SearchItem.cs +++ b/Source/Editor/Windows/Search/SearchItem.cs @@ -74,6 +74,20 @@ namespace FlaxEditor.Windows.Search typeLabel.TextColor = Style.Current.ForegroundGrey; } + /// + public override bool OnMouseDown(Float2 location, MouseButton button) + { + // Select and focus the item on right click to prevent the search from being cleared + if (button == MouseButton.Right) + { + _finder.SelectedItem = this; + _finder.Hand = true; + Focus(); + return true; + } + return base.OnMouseUp(location, button); + } + /// public override bool OnMouseUp(Float2 location, MouseButton button) { @@ -86,6 +100,15 @@ namespace FlaxEditor.Windows.Search return base.OnMouseUp(location, button); } + /// + public override void Draw() + { + if (IsMouseOver) + Render2D.FillRectangle(new Rectangle(Float2.Zero, Size), Style.Current.BackgroundHighlighted); + + base.Draw(); + } + /// public override void OnMouseEnter(Float2 location) { @@ -93,12 +116,7 @@ namespace FlaxEditor.Windows.Search var root = RootWindow; if (root != null) - { root.Cursor = CursorType.Hand; - } - - _finder.SelectedItem = this; - _finder.Hand = true; } /// @@ -176,9 +194,7 @@ namespace FlaxEditor.Windows.Search { string importLocation = System.IO.Path.GetDirectoryName(importPath); if (!string.IsNullOrEmpty(importLocation) && System.IO.Directory.Exists(importLocation)) - { cm.AddButton("Show import location", () => FileSystem.ShowFileExplorer(importLocation)); - } } } cm.AddSeparator(); From 109d4423bb66c60ebe5e71fe04d39e26cf120e68 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Mon, 23 Jun 2025 20:14:18 +0200 Subject: [PATCH 2/3] add accent color strip to search item icons --- Source/Editor/Windows/Search/SearchItem.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Windows/Search/SearchItem.cs b/Source/Editor/Windows/Search/SearchItem.cs index 5336c2855..4d610159e 100644 --- a/Source/Editor/Windows/Search/SearchItem.cs +++ b/Source/Editor/Windows/Search/SearchItem.cs @@ -20,6 +20,11 @@ namespace FlaxEditor.Windows.Search /// protected Image _icon; + /// + /// The color of the accent strip. + /// + protected Color _accentColor; + /// /// The item name. /// @@ -56,7 +61,7 @@ namespace FlaxEditor.Windows.Search var icon = new Image { Size = new Float2(logoSize), - Location = new Float2(5, (height - logoSize) / 2) + Location = new Float2(7, (height - logoSize) / 2) }; _icon = icon; @@ -146,6 +151,7 @@ namespace FlaxEditor.Windows.Search { _asset = item; _asset.AddReference(this); + _accentColor = Editor.Instance.ContentDatabase.GetProxy(item).AccentColor; } /// @@ -228,6 +234,10 @@ namespace FlaxEditor.Windows.Search // Draw icon var iconRect = _icon.Bounds; _asset.DrawThumbnail(ref iconRect); + + // Draw icon color strip + var rect = iconRect with { Width = 2, Height = Height, Location = Float2.Zero }; + Render2D.FillRectangle(rect, _accentColor); } /// From bf10d0949e4aa937eb518570bc6ed36557173f8b Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Thu, 26 Jun 2025 12:47:31 +0200 Subject: [PATCH 3/3] add a bit of spacing to the left edge of the popup to reduce colors bleeding into the background --- Source/Editor/Windows/Search/SearchItem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Editor/Windows/Search/SearchItem.cs b/Source/Editor/Windows/Search/SearchItem.cs index 4d610159e..63263cc58 100644 --- a/Source/Editor/Windows/Search/SearchItem.cs +++ b/Source/Editor/Windows/Search/SearchItem.cs @@ -235,8 +235,8 @@ namespace FlaxEditor.Windows.Search var iconRect = _icon.Bounds; _asset.DrawThumbnail(ref iconRect); - // Draw icon color strip - var rect = iconRect with { Width = 2, Height = Height, Location = Float2.Zero }; + // Draw color strip + var rect = iconRect with { Width = 2, Height = Height, Location = new Float2(2, 0) }; Render2D.FillRectangle(rect, _accentColor); }