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.
This commit is contained in:
1 parent
aca89c631f
commit
88964cab6b
1 file changed
+24
@@ -247,6 +247,8 @@ namespace Cthangover.Mods.Dialog
|
|||||||
|
|
||||||
if (@event.IsActionPressed("ui_accept"))
|
if (@event.IsActionPressed("ui_accept"))
|
||||||
{
|
{
|
||||||
|
if (IsTyping())
|
||||||
|
return;
|
||||||
GameLogger.Log("DIALOG", "input: advancing dialog");
|
GameLogger.Log("DIALOG", "input: advancing dialog");
|
||||||
NextAction();
|
NextAction();
|
||||||
}
|
}
|
||||||
@@ -256,6 +258,9 @@ namespace Cthangover.Mods.Dialog
|
|||||||
if (action == null || action.WaitType == WaitType.WaitTime || action.WaitType == WaitType.WaitEvent)
|
if (action == null || action.WaitType == WaitType.WaitTime || action.WaitType == WaitType.WaitEvent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (IsOverOtherControl())
|
||||||
|
return;
|
||||||
|
|
||||||
if (Body is Control bodyControl)
|
if (Body is Control bodyControl)
|
||||||
{
|
{
|
||||||
var bodyRect = bodyControl.GetGlobalRect();
|
var bodyRect = bodyControl.GetGlobalRect();
|
||||||
@@ -269,6 +274,25 @@ namespace Cthangover.Mods.Dialog
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True while a text field has keyboard focus: Enter and Space belong to
|
||||||
|
/// it, not to the dialog (the dialog reads <c>ui_accept</c> in
|
||||||
|
/// <c>_Input</c>, before the GUI).
|
||||||
|
/// </summary>
|
||||||
|
private bool IsTyping() => GetViewport()?.GuiGetFocusOwner() is LineEdit or TextEdit;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
private bool IsOverOtherControl()
|
||||||
|
{
|
||||||
|
var hovered = GetViewport()?.GuiGetHoveredControl();
|
||||||
|
return hovered != null && hovered != this && !IsAncestorOf(hovered)
|
||||||
|
&& hovered.MouseFilter == MouseFilterEnum.Stop;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Continues a dialog the debugger held (<see cref="DialogRuntime.IsHeld"/>):
|
/// Continues a dialog the debugger held (<see cref="DialogRuntime.IsHeld"/>):
|
||||||
/// runs from the held action on, exactly as if it had never stopped.
|
/// runs from the held action on, exactly as if it had never stopped.
|
||||||
|
|||||||
Reference in new issue
Block a user