Make text fields yield keyboard focus on "Esc" in a consistent way

- search fields clear the input and yield if empty
- chat field and actor edit field yield without clearing
This commit is contained in:
Ivaylo Draganov
2021-07-04 16:24:34 +03:00
committed by abcdefg30
parent df8295fa2c
commit 64e76e1a90
4 changed files with 22 additions and 9 deletions

View File

@@ -133,7 +133,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
filenameInput = panel.Get<TextFieldWidget>("FILENAME_INPUT");
filenameInput.OnTextEdited = () => ApplyFilter();
filenameInput.OnEscKey = _ => filenameInput.YieldKeyboardFocus();
filenameInput.OnEscKey = _ =>
{
if (string.IsNullOrEmpty(filenameInput.Text))
filenameInput.YieldKeyboardFocus();
else
{
filenameInput.Text = "";
filenameInput.OnTextEdited();
}
return true;
};
var frameContainer = panel.GetOrNull("FRAME_SELECTOR");
if (frameContainer != null)