Action UI fixes (#27468)

This commit is contained in:
Leon Friedrich
2024-04-29 20:36:18 +12:00
committed by GitHub
parent 0ab5696391
commit 6471f55a49
2 changed files with 70 additions and 68 deletions

View File

@@ -152,16 +152,8 @@ public sealed class ActionButton : Control, IEntityControl
OnThemeUpdated();
OnKeyBindDown += args =>
{
Depress(args, true);
OnPressed(args);
};
OnKeyBindUp += args =>
{
Depress(args, false);
OnUnpressed(args);
};
OnKeyBindDown += OnPressed;
OnKeyBindUp += OnUnpressed;
TooltipSupplier = SupplyTooltip;
}
@@ -175,11 +167,23 @@ public sealed class ActionButton : Control, IEntityControl
private void OnPressed(GUIBoundKeyEventArgs args)
{
if (args.Function != EngineKeyFunctions.UIClick && args.Function != EngineKeyFunctions.UIRightClick)
return;
if (args.Function == EngineKeyFunctions.UIRightClick)
Depress(args, true);
ActionPressed?.Invoke(args, this);
}
private void OnUnpressed(GUIBoundKeyEventArgs args)
{
if (args.Function != EngineKeyFunctions.UIClick && args.Function != EngineKeyFunctions.UIRightClick)
return;
if (args.Function == EngineKeyFunctions.UIRightClick)
Depress(args, false);
ActionUnpressed?.Invoke(args, this);
}
@@ -378,12 +382,6 @@ public sealed class ActionButton : Control, IEntityControl
if (_action is not {Enabled: true})
return;
if (_depressed && !depress)
{
// fire the action
OnUnpressed(args);
}
_depressed = depress;
DrawModeChanged();
}