From 88964cab6bc0e1c0091f91db174f651028ae30b7 Mon Sep 17 00:00:00 2001 From: iisaev Date: Sun, 18 Oct 2026 15:31:00 +0200 Subject: [PATCH] Dialog box ignores input meant for other controls Enter/Space do not advance the dialog while a text field has focus, and a click over another control that stops the mouse (a tool panel drawn over the dialog area) belongs to that control. DialogBox reads input in _Input, before the GUI, so both used to advance the dialog as well. --- src/UI/Dialog/DialogBox.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/UI/Dialog/DialogBox.cs b/src/UI/Dialog/DialogBox.cs index 7a5bf8b..ca750c2 100644 --- a/src/UI/Dialog/DialogBox.cs +++ b/src/UI/Dialog/DialogBox.cs @@ -247,6 +247,8 @@ namespace Cthangover.Mods.Dialog if (@event.IsActionPressed("ui_accept")) { + if (IsTyping()) + return; GameLogger.Log("DIALOG", "input: advancing dialog"); NextAction(); } @@ -256,6 +258,9 @@ namespace Cthangover.Mods.Dialog if (action == null || action.WaitType == WaitType.WaitTime || action.WaitType == WaitType.WaitEvent) return; + if (IsOverOtherControl()) + return; + if (Body is Control bodyControl) { var bodyRect = bodyControl.GetGlobalRect(); @@ -269,6 +274,25 @@ namespace Cthangover.Mods.Dialog } } + /// + /// True while a text field has keyboard focus: Enter and Space belong to + /// it, not to the dialog (the dialog reads ui_accept in + /// _Input, before the GUI). + /// + private bool IsTyping() => GetViewport()?.GuiGetFocusOwner() is LineEdit or TextEdit; + + /// + /// True when the mouse is over a control that is not part of this box and + /// stops the mouse (a tool panel, a button drawn over the dialog area): + /// the click is meant for that control. + /// + private bool IsOverOtherControl() + { + var hovered = GetViewport()?.GuiGetHoveredControl(); + return hovered != null && hovered != this && !IsAncestorOf(hovered) + && hovered.MouseFilter == MouseFilterEnum.Stop; + } + /// /// Continues a dialog the debugger held (): /// runs from the held action on, exactly as if it had never stopped.