Avoid clearing chat overlay textbox when pressing "back" key binding

Generally this is expected behaviour for usages of focused text boxes
(ie. to clear search content), but not so much here.

Addresses https://github.com/ppy/osu/discussions/19403#discussioncomment-3230395.
This commit is contained in:
Dean Herbert 2022-08-02 13:56:02 +09:00
parent fc0914bf77
commit 34ffc51c51
2 changed files with 8 additions and 1 deletions

View File

@ -21,6 +21,11 @@ public class FocusedTextBox : OsuTextBox, IKeyBindingHandler<GlobalAction>
private bool allowImmediateFocus => host?.OnScreenKeyboardOverlapsGameWindow != true;
/// <summary>
/// Whether the content of the text box should be cleared on the first "back" key press.
/// </summary>
protected virtual bool ClearTextOnBackKey => true;
public void TakeFocus()
{
if (!allowImmediateFocus)
@ -78,7 +83,7 @@ public virtual bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
if (!HasFocus) return false;
if (e.Action == GlobalAction.Back)
if (ClearTextOnBackKey && e.Action == GlobalAction.Back)
{
if (Text.Length > 0)
{

View File

@ -13,6 +13,8 @@ public class ChatTextBox : FocusedTextBox
public override bool HandleLeftRightArrows => !ShowSearch.Value;
protected override bool ClearTextOnBackKey => false;
protected override void LoadComplete()
{
base.LoadComplete();