Skip to content

Commit

Permalink
Merge pull request ppy#27393 from peppy/main-menu-key-delay
Browse files Browse the repository at this point in the history
Fix main menu eating keys if user presses too fast
  • Loading branch information
bdach authored Feb 26, 2024
2 parents ab90b75 + 4c6e8a6 commit 3833f2c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ public void TestGlobalActionHasPriority()
AddAssert("state is top level", () => buttons.State == ButtonSystemState.TopLevel);
}

[Test]
public void TestFastShortcutKeys()
{
AddAssert("state is initial", () => buttons.State == ButtonSystemState.Initial);

AddStep("press P three times", () =>
{
InputManager.Key(Key.P);
InputManager.Key(Key.P);
InputManager.Key(Key.P);
});

AddAssert("entered song select", () => Game.ScreenStack.CurrentScreen is PlaySongSelect);
}

[Test]
public void TestShortcutKeys()
{
Expand Down
4 changes: 4 additions & 0 deletions osu.Game/Screens/Menu/MainMenuButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public ButtonSystemState VisibleState
private Sample? sampleHover;
private SampleChannel? sampleChannel;

public override bool IsPresent => base.IsPresent
// Allow keyboard interaction based on state rather than waiting for delayed animations.
|| state == ButtonState.Expanded;

public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos);

public MainMenuButton(LocalisableString text, string sampleName, IconUsage symbol, Color4 colour, Action? clickAction = null, float extraWidth = 0, params Key[] triggerKeys)
Expand Down

0 comments on commit 3833f2c

Please sign in to comment.