1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:07:44 +08: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:
Dean Herbert 2019-09-05 17:27:48 +09:00 committed by GitHub
commit 986ac08397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -17,7 +17,7 @@ using osuTK.Input;
namespace osu.Game.Tests.Visual.Gameplay
{
[System.ComponentModel.Description("player pause/fail screens")]
[Description("player pause/fail screens")]
public class TestSceneGameplayMenuOverlay : ManualInputManagerTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(FailOverlay), typeof(PauseOverlay) };
@ -152,7 +152,8 @@ namespace osu.Game.Tests.Visual.Gameplay
}
/// <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>
[Test]
public void TestInitialButtonHover()
@ -164,6 +165,10 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("Hide overlay", () => pauseOverlay.Hide());
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);
}

View File

@ -304,6 +304,9 @@ namespace osu.Game.Screens.Play
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)
{
Selected.Value = true;