mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 08:02:55 +08:00
Allow right-clicking to rewind on random button
This commit is contained in:
parent
a9d67d3e92
commit
856ca96b66
@ -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 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
PreviousRandom = () => previousRandomCalled = true,
|
||||
}, null);
|
||||
footer.AddButton(new FooterButtonOptions(), null);
|
||||
|
||||
InputManager.MoveMouseTo(Vector2.Zero);
|
||||
});
|
||||
|
||||
[Test]
|
||||
@ -70,7 +73,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFooterRewindViaMouse()
|
||||
public void TestFooterRewindViaShiftMouseLeft()
|
||||
{
|
||||
AddStep("shift + click button", () =>
|
||||
{
|
||||
@ -81,5 +84,16 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
});
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
@ -73,13 +74,27 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user