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:
@@ -282,6 +282,12 @@ namespace Content.Client.UserInterface
|
||||
_dragDropHelper.EndDrag();
|
||||
}
|
||||
|
||||
private void OnItemFocusExited(ActionMenuItem item)
|
||||
{
|
||||
// lost focus, cancel the drag if one is in progress
|
||||
_dragDropHelper.EndDrag();
|
||||
}
|
||||
|
||||
private void OnItemPressed(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
if (args.Button is not ActionMenuItem actionMenuItem) return;
|
||||
@@ -463,10 +469,9 @@ namespace Content.Client.UserInterface
|
||||
_actionList = actions.ToArray();
|
||||
foreach (var action in _actionList.OrderBy(act => act.Name.ToString()))
|
||||
{
|
||||
var actionItem = new ActionMenuItem(action);
|
||||
var actionItem = new ActionMenuItem(action, OnItemFocusExited);
|
||||
_resultsGrid.Children.Add(actionItem);
|
||||
actionItem.SetActionState(_actionsComponent.IsGranted(action));
|
||||
|
||||
actionItem.OnButtonDown += OnItemButtonDown;
|
||||
actionItem.OnButtonUp += OnItemButtonUp;
|
||||
actionItem.OnPressed += OnItemPressed;
|
||||
|
||||
Reference in New Issue
Block a user