mirror of
https://github.com/ppy/osu
synced 2025-01-31 10:22:02 +00:00
Fix pause menu keyboard navigation being affected by initial cu… (#6002)
Fix pause menu keyboard navigation being affected by initial cursor hover
This commit is contained in:
commit
986ac08397
@ -17,7 +17,7 @@ using osuTK.Input;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
[System.ComponentModel.Description("player pause/fail screens")]
|
[Description("player pause/fail screens")]
|
||||||
public class TestSceneGameplayMenuOverlay : ManualInputManagerTestScene
|
public class TestSceneGameplayMenuOverlay : ManualInputManagerTestScene
|
||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(FailOverlay), typeof(PauseOverlay) };
|
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(FailOverlay), typeof(PauseOverlay) };
|
||||||
@ -152,7 +152,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests that entering menu with cursor initially on button selects it.
|
/// Tests that entering menu with cursor initially on button doesn't selects it immediately.
|
||||||
|
/// This is to allow for stable keyboard navigation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestInitialButtonHover()
|
public void TestInitialButtonHover()
|
||||||
@ -164,6 +165,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddStep("Hide overlay", () => pauseOverlay.Hide());
|
AddStep("Hide overlay", () => pauseOverlay.Hide());
|
||||||
showOverlay();
|
showOverlay();
|
||||||
|
|
||||||
|
AddAssert("First button not selected", () => !getButton(0).Selected.Value);
|
||||||
|
|
||||||
|
AddStep("Move slightly", () => InputManager.MoveMouseTo(InputManager.CurrentState.Mouse.Position + new Vector2(1)));
|
||||||
|
|
||||||
AddAssert("First button selected", () => getButton(0).Selected.Value);
|
AddAssert("First button selected", () => getButton(0).Selected.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,6 +304,9 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private class Button : DialogButton
|
private class Button : DialogButton
|
||||||
{
|
{
|
||||||
|
// required to ensure keyboard navigation always starts from an extremity (unless the cursor is moved)
|
||||||
|
protected override bool OnHover(HoverEvent e) => true;
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||||
{
|
{
|
||||||
Selected.Value = true;
|
Selected.Value = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user