Skip to content

Commit

Permalink
adjust how KeyBindUp retrieves the focused control
Browse files Browse the repository at this point in the history
  • Loading branch information
EmoGarbage404 committed Nov 27, 2023
1 parent 8dc2345 commit 91c9478
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Robust.Client/UserInterface/UserInterfaceManager.Input.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using Robust.Client.Graphics;
Expand Down Expand Up @@ -40,6 +41,7 @@ public Control? ControlFocused
private bool _showingTooltip;
private Control? _suppliedTooltip;
private const float TooltipDelay = 0.25f;
private readonly Dictionary<BoundKeyFunction, Control> _focusedControls = new();

private WindowRoot? _focusedRoot;

Expand Down Expand Up @@ -109,13 +111,14 @@ public void KeyBindDown(BoundKeyEventArgs args)
args.Handle();
}

_focusedControls[args.Function] = control;
OnKeyBindDown?.Invoke(control);
}

public void KeyBindUp(BoundKeyEventArgs args)
{
var control = ControlFocused ?? KeyboardFocused ?? MouseGetControl(args.PointerLocation);
if (control == null)
//var control = ControlFocused ?? KeyboardFocused ?? MouseGetControl(args.PointerLocation);
if (!_focusedControls.TryGetValue(args.Function, out var control))
{
return;
}
Expand All @@ -129,6 +132,7 @@ public void KeyBindUp(BoundKeyEventArgs args)
// Always mark this as handled.
// The only case it should not be is if we do not have a control to click on,
// in which case we never reach this.
_focusedControls.Remove(args.Function);
args.Handle();
}

Expand Down

0 comments on commit 91c9478

Please sign in to comment.