Add Tab navigation for Editor UI

This commit is contained in:
Wojciech Figat
2021-12-21 18:13:45 +01:00
parent c178afdf6b
commit af75751bf1
15 changed files with 293 additions and 195 deletions

View File

@@ -24,6 +24,11 @@ namespace FlaxEditor.Windows
/// </summary>
protected virtual bool CanOpenContentFinder => true;
/// <summary>
/// Gets a value indicating whether this window can use UI navigation (tab/enter).
/// </summary>
protected virtual bool CanUseNavigation => true;
/// <summary>
/// Initializes a new instance of the <see cref="EditorWindow"/> class.
/// </summary>
@@ -184,6 +189,32 @@ namespace FlaxEditor.Windows
#endregion
/// <inheritdoc />
public override bool OnKeyDown(KeyboardKeys key)
{
if (base.OnKeyDown(key))
return true;
switch (key)
{
case KeyboardKeys.Return:
if (CanUseNavigation && Root?.FocusedControl != null)
{
Root.SubmitFocused();
return true;
}
break;
case KeyboardKeys.Tab:
if (CanUseNavigation && Root != null)
{
Root.Navigate(NavDirection.Next);
return true;
}
break;
}
return false;
}
/// <inheritdoc />
public override void OnDestroy()
{