Fix Editor bindings with no modifiers triggering with modifiers pressed
This commit is contained in:
@@ -134,6 +134,57 @@ namespace FlaxEditor.Options
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ProcessModifiers(Control control)
|
||||
{
|
||||
var root = control.Root;
|
||||
bool ctrlPressed = root.GetKey(KeyboardKeys.Control);
|
||||
bool shiftPressed = root.GetKey(KeyboardKeys.Shift);
|
||||
bool altPressed = root.GetKey(KeyboardKeys.Alt);
|
||||
|
||||
bool mod1 = false;
|
||||
if (Modifier1 == KeyboardKeys.None)
|
||||
mod1 = true;
|
||||
else if (Modifier1 == KeyboardKeys.Control)
|
||||
{
|
||||
mod1 = ctrlPressed;
|
||||
ctrlPressed = false;
|
||||
}
|
||||
else if (Modifier1 == KeyboardKeys.Shift)
|
||||
{
|
||||
mod1 = shiftPressed;
|
||||
shiftPressed = false;
|
||||
}
|
||||
else if (Modifier1 == KeyboardKeys.Alt)
|
||||
{
|
||||
mod1 = altPressed;
|
||||
altPressed = false;
|
||||
}
|
||||
|
||||
bool mod2 = false;
|
||||
if (Modifier2 == KeyboardKeys.None)
|
||||
mod2 = true;
|
||||
else if (Modifier2 == KeyboardKeys.Control)
|
||||
{
|
||||
mod2 = ctrlPressed;
|
||||
ctrlPressed = false;
|
||||
}
|
||||
else if (Modifier2 == KeyboardKeys.Shift)
|
||||
{
|
||||
mod2 = shiftPressed;
|
||||
shiftPressed = false;
|
||||
}
|
||||
else if (Modifier2 == KeyboardKeys.Alt)
|
||||
{
|
||||
mod2 = altPressed;
|
||||
altPressed = false;
|
||||
}
|
||||
|
||||
// Check if any unhandled modifiers are not pressed
|
||||
if (mod1 && mod2)
|
||||
return !ctrlPressed && !shiftPressed && !altPressed;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes this input binding to check if state matches.
|
||||
/// </summary>
|
||||
@@ -142,19 +193,7 @@ namespace FlaxEditor.Options
|
||||
public bool Process(Control control)
|
||||
{
|
||||
var root = control.Root;
|
||||
|
||||
if (root.GetKey(Key))
|
||||
{
|
||||
if (Modifier1 == KeyboardKeys.None || root.GetKey(Modifier1))
|
||||
{
|
||||
if (Modifier2 == KeyboardKeys.None || root.GetKey(Modifier2))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return root.GetKey(Key) && ProcessModifiers(control);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -165,20 +204,10 @@ namespace FlaxEditor.Options
|
||||
/// <returns>True if input has been processed, otherwise false.</returns>
|
||||
public bool Process(Control control, KeyboardKeys key)
|
||||
{
|
||||
var root = control.Root;
|
||||
if (key != Key)
|
||||
return false;
|
||||
|
||||
if (key == Key)
|
||||
{
|
||||
if (Modifier1 == KeyboardKeys.None || root.GetKey(Modifier1))
|
||||
{
|
||||
if (Modifier2 == KeyboardKeys.None || root.GetKey(Modifier2))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return ProcessModifiers(control);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user