1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 11:47:24 +08:00

Merge pull request #30206 from minetoblend/fix/selection-box-buttons-stuck

Fix SelectionBox buttons freezing when button is triggered via key event
This commit is contained in:
Dan Balasescu 2024-10-11 12:02:58 +09:00 committed by GitHub
commit 616c2aeefc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 8 deletions

View File

@ -150,13 +150,25 @@ namespace osu.Game.Screens.Edit.Compose.Components
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 @@ namespace osu.Game.Screens.Edit.Compose.Components
Action = action
};
button.OperationStarted += freezeButtonPosition;
button.Clicked += freezeButtonPosition;
button.HoverLost += unfreezeButtonPosition;
button.OperationStarted += operationStarted;

View File

@ -21,6 +21,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
public Action? Action;
public event Action? Clicked;
public event Action? HoverLost;
public SelectionBoxButton(IconUsage iconUsage, string tooltip)
@ -49,11 +51,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override bool OnClick(ClickEvent e)
{
Circle.FlashColour(Colours.GrayF, 300);
Clicked?.Invoke();
TriggerAction();
TriggerOperationStarted();
Action?.Invoke();
TriggerOperationEnded();
return true;
}
@ -71,5 +72,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
}
public LocalisableString TooltipText { get; }
public void TriggerAction()
{
Circle.FlashColour(Colours.GrayF, 300);
TriggerOperationStarted();
Action?.Invoke();
TriggerOperationEnded();
}
}
}