Fix gameplay chat display not losing focus on escape key press

Closes #15293.
This commit is contained in:
Dean Herbert 2021-10-26 13:55:02 +09:00
parent 8015791d4c
commit 6c38028d06
2 changed files with 22 additions and 0 deletions

View File

@ -92,6 +92,18 @@ public void TestFocusOnTabKeyWhenExpanded()
assertChatFocused(true); assertChatFocused(true);
} }
[Test]
public void TestFocusLostOnBackKey()
{
setLocalUserPlaying(true);
assertChatFocused(false);
AddStep("press tab", () => InputManager.Key(Key.Tab));
assertChatFocused(true);
AddStep("press escape", () => InputManager.Key(Key.Escape));
assertChatFocused(false);
}
[Test] [Test]
public void TestFocusOnTabKeyWhenNotExpanded() public void TestFocusOnTabKeyWhenNotExpanded()
{ {

View File

@ -10,6 +10,7 @@
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Match.Components; using osu.Game.Screens.OnlinePlay.Match.Components;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osuTK.Input;
namespace osu.Game.Screens.OnlinePlay.Multiplayer namespace osu.Game.Screens.OnlinePlay.Multiplayer
{ {
@ -75,6 +76,15 @@ public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{ {
switch (e.Action) switch (e.Action)
{ {
case GlobalAction.Back:
if (Textbox.HasFocus)
{
Schedule(() => Textbox.KillFocus());
return true;
}
break;
case GlobalAction.ToggleChatFocus: case GlobalAction.ToggleChatFocus:
if (Textbox.HasFocus) if (Textbox.HasFocus)
{ {