Tidy up conditionals

This commit is contained in:
Dean Herbert
2017-08-22 18:21:00 +09:00
parent a26885c1ab
commit 97acff535d

View File

@ -136,40 +136,34 @@ namespace osu.Game.Overlays.KeyBinding
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{ {
if (HasFocus) if (!HasFocus || !bindTarget.IsHovered)
{ return base.OnMouseDown(state, args);
if (bindTarget.IsHovered)
{
if (!AllowMainMouseButtons)
{
switch (args.Button)
{
case MouseButton.Left:
case MouseButton.Right:
return true;
}
}
bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(state)); if (!AllowMainMouseButtons)
return true; {
switch (args.Button)
{
case MouseButton.Left:
case MouseButton.Right:
return true;
} }
} }
return base.OnMouseDown(state, args); bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(state));
return true;
} }
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{ {
if (HasFocus && !state.Mouse.Buttons.Any()) // don't do anything until the last button is released.
{ if (!HasFocus || state.Mouse.Buttons.Any())
if (bindTarget.IsHovered) return base.OnMouseUp(state, args);
finalise();
else
updateBindTarget();
return true;
}
return base.OnMouseUp(state, args); if (bindTarget.IsHovered)
finalise();
else
updateBindTarget();
return true;
} }
protected override bool OnWheel(InputState state) protected override bool OnWheel(InputState state)
@ -211,13 +205,10 @@ namespace osu.Game.Overlays.KeyBinding
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
{ {
if (HasFocus) if (!HasFocus) return base.OnKeyUp(state, args);
{
finalise();
return true;
}
return base.OnKeyUp(state, args); finalise();
return true;
} }
private void finalise() private void finalise()