From c739447598bf17a60df403f4da5446295bf02168 Mon Sep 17 00:00:00 2001 From: Gustas <37534529+PunkPun@users.noreply.github.com> Date: Mon, 5 Dec 2022 19:38:40 +0200 Subject: [PATCH] Fix map editor sliders stealing focus --- OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs index 96152f0a82..a63c4f5c75 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs @@ -41,6 +41,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic readonly BackgroundWidget actorEditPanel; readonly LabelWidget typeLabel; readonly TextFieldWidget actorIDField; + readonly HashSet typableFields = new HashSet(); readonly LabelWidget actorIDErrorLabel; readonly Widget initContainer; @@ -328,6 +329,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (float.TryParse(valueField.Text, out var result)) slider.UpdateValue(result); }; + + valueField.OnEscKey = _ => { valueField.YieldKeyboardFocus(); return true; }; + valueField.OnEnterKey = _ => { valueField.YieldKeyboardFocus(); return true; }; + typableFields.Add(valueField); } initContainer.AddChild(sliderContainer); @@ -402,6 +407,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic void Close() { actorIDField.YieldKeyboardFocus(); + foreach (var f in typableFields) + f.YieldKeyboardFocus(); + editor.DefaultBrush.SelectedActor = null; CurrentActor = null; }