Skip to content

Commit

Permalink
simplify logic with finally
Browse files Browse the repository at this point in the history
  • Loading branch information
OliBomby committed Oct 10, 2024
1 parent 178baff commit 3ed2e1e
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,29 +149,27 @@ protected override bool OnKeyDown(KeyDownEvent e)
if (e.Repeat || !e.ControlPressed)
return false;

// We don't want to freeze the buttons when we're using the keyboard to click the buttons, because we might not be hovering them.
dontFreezeButtonPosition = true;
bool handled = false;

switch (e.Key)
try
{
case Key.G:
handled = CanReverse && reverseButton?.TriggerClick() == true;
break;

case Key.Comma:
handled = canRotate.Value && rotateCounterClockwiseButton?.TriggerClick() == true;
break;
// We don't want to freeze the buttons when we're using the keyboard to click the buttons, because we might not be hovering them.
dontFreezeButtonPosition = true;

case Key.Period:
handled = canRotate.Value && rotateClockwiseButton?.TriggerClick() == true;
break;
}
switch (e.Key)
{
case Key.G:
return CanReverse && reverseButton?.TriggerClick() == true;

dontFreezeButtonPosition = false;
case Key.Comma:
return canRotate.Value && rotateCounterClockwiseButton?.TriggerClick() == true;

if (handled)
return true;
case Key.Period:
return canRotate.Value && rotateClockwiseButton?.TriggerClick() == true;
}
}
finally
{
dontFreezeButtonPosition = false;
}

return base.OnKeyDown(e);
}
Expand Down

0 comments on commit 3ed2e1e

Please sign in to comment.