diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs index d685fe74b0..2171ba696f 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs @@ -150,13 +150,25 @@ protected override bool OnKeyDown(KeyDownEvent e) switch (e.Key) { case Key.G: - return CanReverse && reverseButton?.TriggerClick() == true; + if (!CanReverse || reverseButton == null) + return false; + + reverseButton.TriggerAction(); + return true; case Key.Comma: - return canRotate.Value && rotateCounterClockwiseButton?.TriggerClick() == true; + if (!canRotate.Value || rotateCounterClockwiseButton == null) + return false; + + rotateCounterClockwiseButton.TriggerAction(); + return true; case Key.Period: - return canRotate.Value && rotateClockwiseButton?.TriggerClick() == true; + if (!canRotate.Value || rotateClockwiseButton == null) + return false; + + rotateClockwiseButton.TriggerAction(); + return true; } return base.OnKeyDown(e); @@ -285,7 +297,7 @@ private SelectionBoxButton addButton(IconUsage icon, string tooltip, Action acti Action = action }; - button.OperationStarted += freezeButtonPosition; + button.Clicked += freezeButtonPosition; button.HoverLost += unfreezeButtonPosition; button.OperationStarted += operationStarted; diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs index e355add40b..8f263cdf4f 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs @@ -21,6 +21,8 @@ public sealed partial class SelectionBoxButton : SelectionBoxControl, IHasToolti public Action? Action; + public event Action? Clicked; + public event Action? HoverLost; public SelectionBoxButton(IconUsage iconUsage, string tooltip) @@ -49,11 +51,10 @@ private void load() protected override bool OnClick(ClickEvent e) { - Circle.FlashColour(Colours.GrayF, 300); + Clicked?.Invoke(); + + TriggerAction(); - TriggerOperationStarted(); - Action?.Invoke(); - TriggerOperationEnded(); return true; } @@ -71,5 +72,14 @@ protected override void OnHoverLost(HoverLostEvent e) } public LocalisableString TooltipText { get; } + + public void TriggerAction() + { + Circle.FlashColour(Colours.GrayF, 300); + + TriggerOperationStarted(); + Action?.Invoke(); + TriggerOperationEnded(); + } } }