Slightly tweak the key processing code

This commit is contained in:
stefnotch
2021-01-27 22:08:17 +01:00
parent f00ae7fb21
commit c820e87d4a
2 changed files with 29 additions and 11 deletions

View File

@@ -143,7 +143,30 @@ namespace FlaxEditor.Options
{
var root = control.Root;
if (root.GetKeyDown(Key))
if (root.GetKey(Key))
{
if (Modifier1 == KeyboardKeys.None || root.GetKey(Modifier1))
{
if (Modifier2 == KeyboardKeys.None || root.GetKey(Modifier2))
{
return true;
}
}
}
return false;
}
/// <summary>
/// Processes this input binding to check if state matches.
/// </summary>
/// <param name="control">The input providing control.</param>
/// <returns>True if input has been processed, otherwise false.</returns>
public bool Process(Control control, KeyboardKeys key)
{
var root = control.Root;
if (key == Key)
{
if (Modifier1 == KeyboardKeys.None || root.GetKey(Modifier1))
{
@@ -435,16 +458,10 @@ namespace FlaxEditor.Options
for (int i = 0; i < _bindings.Count; i++)
{
var binding = _bindings[i].Binder(options);
if (binding.Key == key)
if (binding.Process(control, key))
{
if (binding.Modifier1 == KeyboardKeys.None || root.GetKey(binding.Modifier1))
{
if (binding.Modifier2 == KeyboardKeys.None || root.GetKey(binding.Modifier2))
{
_bindings[i].Callback();
return true;
}
}
_bindings[i].Callback();
return true;
}
}

View File

@@ -387,8 +387,9 @@ namespace FlaxEditor.Windows
}
}
// Prevent closing the game window tab during a play session
if (Editor.StateMachine.IsPlayMode && Editor.Options.Options.Input.CloseTab.Process(Root))
if (Editor.StateMachine.IsPlayMode && Editor.Options.Options.Input.CloseTab.Process(this, key))
{
return true;
}