Fix "stuck" drag/drop controls using ControlFocusExited (#2828)

* #1449 use new ControlFocusExited override for drag/drop controls to avoid getting
"stuck" dragging when the control lost focus mid drag, also use the renamed
KeyboardFocusEntered/Exited methods.

* Update Content.Client/UserInterface/ActionMenuItem.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Update ActionMenuItem.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
chairbender
2021-01-13 14:20:23 -08:00
committed by GitHub
parent 1f18dd568a
commit 803eda40c3
4 changed files with 28 additions and 4 deletions

View File

@@ -1,5 +1,7 @@
#nullable enable
using System;
using Content.Client.GameObjects.Components.Mobs;
using Content.Client.UserInterface.Stylesheets;
using Content.Shared.Actions;
using Robust.Client.UserInterface;
@@ -19,8 +21,11 @@ namespace Content.Client.UserInterface
public BaseActionPrototype Action { get; private set; }
public ActionMenuItem(BaseActionPrototype action)
private Action<ActionMenuItem> _onControlFocusExited;
public ActionMenuItem(BaseActionPrototype action, Action<ActionMenuItem> onControlFocusExited)
{
_onControlFocusExited = onControlFocusExited;
Action = action;
CustomMinimumSize = (64, 64);
@@ -38,6 +43,12 @@ namespace Content.Client.UserInterface
TooltipSupplier = SupplyTooltip;
}
protected override void ControlFocusExited()
{
base.ControlFocusExited();
_onControlFocusExited.Invoke(this);
}
private Control SupplyTooltip(Control? sender)
{
return new ActionAlertTooltip(Action.Name, Action.Description, Action.Requires);