mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 21:23:04 +08:00
Merge pull request #1785 from FreezyLemon/fix-pause-overlay-selection
Select pause buttons only on mouse move
This commit is contained in:
commit
8f716212a7
@ -73,7 +73,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
AddStep("Show overlay", () => failOverlay.Show());
|
AddStep("Show overlay", () => failOverlay.Show());
|
||||||
|
|
||||||
AddStep("Hover first button", () => failOverlay.Buttons.First().TriggerOnHover(null));
|
AddStep("Hover first button", () => failOverlay.Buttons.First().TriggerOnMouseMove(null));
|
||||||
AddStep("Hide overlay", () => failOverlay.Hide());
|
AddStep("Hide overlay", () => failOverlay.Hide());
|
||||||
|
|
||||||
AddAssert("Overlay state is reset", () => !failOverlay.Buttons.Any(b => b.Selected));
|
AddAssert("Overlay state is reset", () => !failOverlay.Buttons.Any(b => b.Selected));
|
||||||
@ -162,7 +162,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
var secondButton = pauseOverlay.Buttons.Skip(1).First();
|
var secondButton = pauseOverlay.Buttons.Skip(1).First();
|
||||||
|
|
||||||
AddStep("Down arrow", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Down }));
|
AddStep("Down arrow", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Down }));
|
||||||
AddStep("Hover second button", () => secondButton.TriggerOnHover(null));
|
AddStep("Hover second button", () => secondButton.TriggerOnMouseMove(null));
|
||||||
AddAssert("First button not selected", () => !pauseOverlay.Buttons.First().Selected);
|
AddAssert("First button not selected", () => !pauseOverlay.Buttons.First().Selected);
|
||||||
AddAssert("Second button selected", () => secondButton.Selected);
|
AddAssert("Second button selected", () => secondButton.Selected);
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
var secondButton = pauseOverlay.Buttons.Skip(1).First();
|
var secondButton = pauseOverlay.Buttons.Skip(1).First();
|
||||||
|
|
||||||
AddStep("Hover second button", () => secondButton.TriggerOnHover(null));
|
AddStep("Hover second button", () => secondButton.TriggerOnMouseMove(null));
|
||||||
AddStep("Up arrow", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Up }));
|
AddStep("Up arrow", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Up }));
|
||||||
AddAssert("Second button not selected", () => !secondButton.Selected);
|
AddAssert("Second button not selected", () => !secondButton.Selected);
|
||||||
AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected);
|
AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected);
|
||||||
@ -195,7 +195,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
var secondButton = pauseOverlay.Buttons.Skip(1).First();
|
var secondButton = pauseOverlay.Buttons.Skip(1).First();
|
||||||
|
|
||||||
AddStep("Hover second button", () => secondButton.TriggerOnHover(null));
|
AddStep("Hover second button", () => secondButton.TriggerOnMouseMove(null));
|
||||||
AddStep("Unhover second button", () => secondButton.TriggerOnHoverLost(null));
|
AddStep("Unhover second button", () => secondButton.TriggerOnHoverLost(null));
|
||||||
AddStep("Down arrow", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Down }));
|
AddStep("Down arrow", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Down }));
|
||||||
AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected); // Initial state condition
|
AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected); // Initial state condition
|
||||||
|
@ -263,6 +263,14 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private class Button : DialogButton
|
private class Button : DialogButton
|
||||||
{
|
{
|
||||||
|
protected override bool OnHover(InputState state) => true;
|
||||||
|
|
||||||
|
protected override bool OnMouseMove(InputState state)
|
||||||
|
{
|
||||||
|
Selected.Value = true;
|
||||||
|
return base.OnMouseMove(state);
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
{
|
{
|
||||||
if (args.Repeat || args.Key != Key.Enter || !Selected)
|
if (args.Repeat || args.Key != Key.Enter || !Selected)
|
||||||
|
Loading…
Reference in New Issue
Block a user