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:
committed by
abcdefg30
parent
df8295fa2c
commit
64e76e1a90
@@ -133,7 +133,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
filenameInput = panel.Get<TextFieldWidget>("FILENAME_INPUT");
|
filenameInput = panel.Get<TextFieldWidget>("FILENAME_INPUT");
|
||||||
filenameInput.OnTextEdited = () => ApplyFilter();
|
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");
|
var frameContainer = panel.GetOrNull("FRAME_SELECTOR");
|
||||||
if (frameContainer != null)
|
if (frameContainer != null)
|
||||||
|
|||||||
@@ -114,11 +114,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
&& editor.CurrentBrush == editor.DefaultBrush
|
&& editor.CurrentBrush == editor.DefaultBrush
|
||||||
&& Game.RunTime > lastScrollTime + scrollVisibleTimeout;
|
&& Game.RunTime > lastScrollTime + scrollVisibleTimeout;
|
||||||
|
|
||||||
actorIDField.OnEscKey = _ =>
|
actorIDField.OnEscKey = _ => actorIDField.YieldKeyboardFocus();
|
||||||
{
|
|
||||||
actorIDField.YieldKeyboardFocus();
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
actorIDField.OnTextEdited = () =>
|
actorIDField.OnTextEdited = () =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,8 +46,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
SearchTextField = widget.Get<TextFieldWidget>("SEARCH_TEXTFIELD");
|
SearchTextField = widget.Get<TextFieldWidget>("SEARCH_TEXTFIELD");
|
||||||
SearchTextField.OnEscKey = _ =>
|
SearchTextField.OnEscKey = _ =>
|
||||||
{
|
{
|
||||||
SearchTextField.Text = "";
|
if (string.IsNullOrEmpty(SearchTextField.Text))
|
||||||
SearchTextField.YieldKeyboardFocus();
|
SearchTextField.YieldKeyboardFocus();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SearchTextField.Text = "";
|
||||||
|
SearchTextField.OnTextEdited();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -436,7 +436,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
chatTextField.OnEscKey = _ => { chatTextField.Text = ""; return true; };
|
chatTextField.OnEscKey = _ => chatTextField.YieldKeyboardFocus();
|
||||||
|
|
||||||
lobbyChatPanel = lobby.Get<ScrollPanelWidget>("CHAT_DISPLAY");
|
lobbyChatPanel = lobby.Get<ScrollPanelWidget>("CHAT_DISPLAY");
|
||||||
chatTemplate = lobbyChatPanel.Get("CHAT_TEMPLATE");
|
chatTemplate = lobbyChatPanel.Get("CHAT_TEMPLATE");
|
||||||
|
|||||||
Reference in New Issue
Block a user