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

@@ -220,6 +220,14 @@ namespace FlaxEditor.GUI.Dialogs
}
}
/// <summary>
/// Called to cancel action and close the dialog.
/// </summary>
public virtual void OnCancel()
{
Close(DialogResult.Cancel);
}
/// <summary>
/// Closes dialog with the specified result.
/// </summary>
@@ -243,6 +251,7 @@ namespace FlaxEditor.GUI.Dialogs
/// </summary>
protected virtual void OnShow()
{
Focus();
}
/// <summary>
@@ -254,5 +263,37 @@ namespace FlaxEditor.GUI.Dialogs
{
return true;
}
/// <inheritdoc />
public override void OnSubmit()
{
base.OnSubmit();
Close(DialogResult.OK);
}
/// <inheritdoc />
public override bool OnKeyDown(KeyboardKeys key)
{
if (base.OnKeyDown(key))
return true;
switch (key)
{
case KeyboardKeys.Return:
if (Root?.FocusedControl != null)
Root.SubmitFocused();
else
OnSubmit();
return true;
case KeyboardKeys.Escape:
OnCancel();
return true;
case KeyboardKeys.Tab:
Root?.Navigate(NavDirection.Next);
return true;
}
return false;
}
}
}