Skip to content

Commit c579d3b

Browse files
committed
Remove key handling from ContainerWidget
It has no business handling key input. This was used only for opening the ingame chat and replacing it with a `LogicKeyListener` was trivial.
1 parent ec7479a commit c579d3b

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

OpenRA.Game/Widgets/ContainerWidget.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
*/
1010
#endregion
1111

12-
using System;
13-
1412
namespace OpenRA.Widgets
1513
{
1614
public class ContainerWidget : Widget
@@ -27,8 +25,6 @@ public ContainerWidget(ContainerWidget other)
2725

2826
public override string GetCursor(int2 pos) { return null; }
2927
public override Widget Clone() { return new ContainerWidget(this); }
30-
public Func<KeyInput, bool> OnKeyPress = _ => false;
31-
public override bool HandleKeyPress(KeyInput e) { return OnKeyPress(e); }
3228

3329
public override bool HandleMouseInput(MouseInput mi)
3430
{

OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ public IngameChatLogic(Widget widget, OrderManager orderManager, World world, Mo
209209
var chatClose = chatChrome.Get<ButtonWidget>("CHAT_CLOSE");
210210
chatClose.OnClick += CloseChat;
211211

212-
chatPanel.OnKeyPress = e =>
212+
var openChatKeyListener = chatPanel.Get<LogicKeyListenerWidget>("OPEN_CHAT_KEY_LISTENER");
213+
214+
openChatKeyListener.AddHandler(e =>
213215
{
214216
if (e.Event == KeyInputEvent.Up)
215217
return false;
@@ -223,7 +225,7 @@ public IngameChatLogic(Widget widget, OrderManager orderManager, World world, Mo
223225
}
224226

225227
return false;
226-
};
228+
});
227229
}
228230

229231
chatScrollPanel = chatChrome.Get<ScrollPanelWidget>("CHAT_SCROLLPANEL");

mods/cnc/chrome/ingame-chat.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Container@CHAT_PANEL:
1111
System: SYSTEM_LINE_TEMPLATE
1212
Mission: CHAT_LINE_TEMPLATE
1313
Children:
14+
LogicKeyListener@OPEN_CHAT_KEY_LISTENER:
1415
Container@CHAT_OVERLAY:
1516
Width: PARENT_RIGHT - 24
1617
Height: PARENT_BOTTOM - 30

mods/common/chrome/ingame-chat.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Container@CHAT_PANEL:
1111
System: SYSTEM_LINE_TEMPLATE
1212
Mission: CHAT_LINE_TEMPLATE
1313
Children:
14+
LogicKeyListener@OPEN_CHAT_KEY_LISTENER:
1415
Container@CHAT_OVERLAY:
1516
Width: PARENT_RIGHT - 24
1617
Height: PARENT_BOTTOM - 30

0 commit comments

Comments
 (0)