Skip to content

Commit e2b7a87

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 a69ea79 commit e2b7a87

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

OpenRA.Game/Widgets/Widget.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,6 @@ public ContainerWidget(ContainerWidget other)
632632

633633
public override string GetCursor(int2 pos) { return null; }
634634
public override Widget Clone() { return new ContainerWidget(this); }
635-
public Func<KeyInput, bool> OnKeyPress = _ => false;
636-
public override bool HandleKeyPress(KeyInput e) { return OnKeyPress(e); }
637635

638636
public override bool HandleMouseInput(MouseInput mi)
639637
{

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)