diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs index 83e789bd0e..38e05fb610 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs @@ -131,6 +131,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic CloseChat(); chatText.IsDisabled = () => world.IsReplay; + + var keyListener = chatChrome.Get("KEY_LISTENER"); + keyListener.OnKeyPress = e => + { + if (e.Event == KeyInputEvent.Up || !chatText.IsDisabled()) + return false; + + if ((e.Key == Keycode.RETURN || e.Key == Keycode.KP_ENTER || e.Key == Keycode.ESCAPE) && e.Modifiers == Modifiers.None) + { + CloseChat(); + return true; + } + + return false; + }; } bool SwitchTeamChat() @@ -151,7 +166,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic chatText.Text = ""; chatChrome.Visible = true; chatScrollPanel.ScrollToBottom(); - chatText.TakeKeyboardFocus(); + if (!chatText.IsDisabled()) + chatText.TakeKeyboardFocus(); chatOverlay.Visible = false; } diff --git a/mods/cnc/chrome/ingame-chat.yaml b/mods/cnc/chrome/ingame-chat.yaml index c06fe890cf..09aad67893 100644 --- a/mods/cnc/chrome/ingame-chat.yaml +++ b/mods/cnc/chrome/ingame-chat.yaml @@ -41,6 +41,7 @@ Container@CHAT_PANEL: ImageName: kick X: 6 Y: 8 + LogicKeyListener@KEY_LISTENER: ScrollPanel@CHAT_SCROLLPANEL: Y: PARENT_BOTTOM - HEIGHT - 30 Width: 550 diff --git a/mods/ra/chrome/ingame-chat.yaml b/mods/ra/chrome/ingame-chat.yaml index 530ff7f4e2..2ab1347b7c 100644 --- a/mods/ra/chrome/ingame-chat.yaml +++ b/mods/ra/chrome/ingame-chat.yaml @@ -37,6 +37,7 @@ Container@CHAT_PANEL: Height: 25 Text: X Font: Bold + LogicKeyListener@KEY_LISTENER: ScrollPanel@CHAT_SCROLLPANEL: Y: PARENT_BOTTOM - HEIGHT - 30 Width: 550