Skip to content

Commit

Permalink
Remove key handling from ContainerWidget
Browse files Browse the repository at this point in the history
It has no business handling key input. This was used only for opening the ingame chat and replacing it with a `LogicKeyListener` was trivial.
  • Loading branch information
dragunoff committed Sep 30, 2024
1 parent ec7479a commit c579d3b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 0 additions & 4 deletions OpenRA.Game/Widgets/ContainerWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
*/
#endregion

using System;

namespace OpenRA.Widgets
{
public class ContainerWidget : Widget
Expand All @@ -27,8 +25,6 @@ public ContainerWidget(ContainerWidget other)

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

public override bool HandleMouseInput(MouseInput mi)
{
Expand Down
6 changes: 4 additions & 2 deletions OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ public IngameChatLogic(Widget widget, OrderManager orderManager, World world, Mo
var chatClose = chatChrome.Get<ButtonWidget>("CHAT_CLOSE");
chatClose.OnClick += CloseChat;

chatPanel.OnKeyPress = e =>
var openChatKeyListener = chatPanel.Get<LogicKeyListenerWidget>("OPEN_CHAT_KEY_LISTENER");

openChatKeyListener.AddHandler(e =>
{
if (e.Event == KeyInputEvent.Up)
return false;
Expand All @@ -223,7 +225,7 @@ public IngameChatLogic(Widget widget, OrderManager orderManager, World world, Mo
}
return false;
};
});
}

chatScrollPanel = chatChrome.Get<ScrollPanelWidget>("CHAT_SCROLLPANEL");
Expand Down
1 change: 1 addition & 0 deletions mods/cnc/chrome/ingame-chat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Container@CHAT_PANEL:
System: SYSTEM_LINE_TEMPLATE
Mission: CHAT_LINE_TEMPLATE
Children:
LogicKeyListener@OPEN_CHAT_KEY_LISTENER:
Container@CHAT_OVERLAY:
Width: PARENT_RIGHT - 24
Height: PARENT_BOTTOM - 30
Expand Down
1 change: 1 addition & 0 deletions mods/common/chrome/ingame-chat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Container@CHAT_PANEL:
System: SYSTEM_LINE_TEMPLATE
Mission: CHAT_LINE_TEMPLATE
Children:
LogicKeyListener@OPEN_CHAT_KEY_LISTENER:
Container@CHAT_OVERLAY:
Width: PARENT_RIGHT - 24
Height: PARENT_BOTTOM - 30
Expand Down

0 comments on commit c579d3b

Please sign in to comment.