Merge pull request #12043 from bdach/fix-reverse-crash

Fix selection box operation hotkeys not registering in change handler
This commit is contained in:
Dan Balasescu 2021-03-18 13:30:33 +09:00 committed by GitHub
commit b3e96c8385
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -113,16 +113,25 @@ namespace osu.Game.Screens.Edit.Compose.Components
if (e.Repeat || !e.ControlPressed)
return false;
bool runOperationFromHotkey(Func<bool> operation)
{
operationStarted();
bool result = operation?.Invoke() ?? false;
operationEnded();
return result;
}
switch (e.Key)
{
case Key.G:
return CanReverse && OnReverse?.Invoke() == true;
return CanReverse && runOperationFromHotkey(OnReverse);
case Key.H:
return CanScaleX && OnFlip?.Invoke(Direction.Horizontal) == true;
return CanScaleX && runOperationFromHotkey(() => OnFlip?.Invoke(Direction.Horizontal) ?? false);
case Key.J:
return CanScaleY && OnFlip?.Invoke(Direction.Vertical) == true;
return CanScaleY && runOperationFromHotkey(() => OnFlip?.Invoke(Direction.Vertical) ?? false);
}
return base.OnKeyDown(e);