diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneSongSelectFooter.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneSongSelectFooter.cs index 6485123b29f9..f27615eea5be 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneSongSelectFooter.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneSongSelectFooter.cs @@ -4,6 +4,7 @@ using NUnit.Framework; using osu.Framework.Graphics; using osu.Game.Screens.Select; +using osuTK; using osuTK.Input; namespace osu.Game.Tests.Visual.SongSelect @@ -36,6 +37,8 @@ public void SetUp() => Schedule(() => PreviousRandom = () => previousRandomCalled = true, }, null); footer.AddButton(new FooterButtonOptions(), null); + + InputManager.MoveMouseTo(Vector2.Zero); }); [Test] @@ -70,7 +73,7 @@ public void TestFooterRewind() } [Test] - public void TestFooterRewindViaMouse() + public void TestFooterRewindViaShiftMouseLeft() { AddStep("shift + click button", () => { @@ -81,5 +84,16 @@ public void TestFooterRewindViaMouse() }); AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled); } + + [Test] + public void TestFooterRewindViaMouseRight() + { + AddStep("right click button", () => + { + InputManager.MoveMouseTo(randomButton); + InputManager.Click(MouseButton.Right); + }); + AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled); + } } } diff --git a/osu.Game/Screens/Select/FooterButtonRandom.cs b/osu.Game/Screens/Select/FooterButtonRandom.cs index 5f8fdce05494..48d58368266a 100644 --- a/osu.Game/Screens/Select/FooterButtonRandom.cs +++ b/osu.Game/Screens/Select/FooterButtonRandom.cs @@ -10,6 +10,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Input.Bindings; using osuTK; +using osuTK.Input; namespace osu.Game.Screens.Select { @@ -73,13 +74,27 @@ protected override void OnKeyUp(KeyUpEvent e) protected override bool OnClick(ClickEvent e) { - rewindSearch = e.ShiftPressed; - return base.OnClick(e); + try + { + // this uses OR to handle rewinding when clicks are triggered by other sources (i.e. right button in OnMouseUp). + rewindSearch |= e.ShiftPressed; + return base.OnClick(e); + } + finally + { + rewindSearch = false; + } } protected override void OnMouseUp(MouseUpEvent e) { - rewindSearch = false; + if (e.Button == MouseButton.Right) + { + rewindSearch = true; + TriggerClick(); + return; + } + base.OnMouseUp(e); }