From 8a01a31e8dcb600b1f2df73e111bcaaf5eed7c82 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 15 Apr 2022 17:12:50 +0200 Subject: [PATCH] Add keyboard key navigation to Content View based on items name first character --- Source/Editor/Content/GUI/ContentView.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Source/Editor/Content/GUI/ContentView.cs b/Source/Editor/Content/GUI/ContentView.cs index 79e4cd0c0..5d6041af0 100644 --- a/Source/Editor/Content/GUI/ContentView.cs +++ b/Source/Editor/Content/GUI/ContentView.cs @@ -689,6 +689,30 @@ namespace FlaxEditor.Content.GUI return base.OnKeyDown(key); } + /// + public override bool OnCharInput(char c) + { + if (base.OnCharInput(c)) + return true; + + if (char.IsLetterOrDigit(c) && _items.Count != 0) + { + // Jump to the item starting with this character + c = char.ToLowerInvariant(c); + for (int i = 0; i < _items.Count; i++) + { + var name = _items[i].ShortName; + if (!string.IsNullOrEmpty(name) && char.ToLowerInvariant(name[0]) == c) + { + Select(_items[i]); + break; + } + } + } + + return false; + } + /// protected override void PerformLayoutBeforeChildren() {