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:
commit
986ac08397
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user