mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 13:47:38 +08:00
34ffc51c51
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.
40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using osu.Framework.Bindables;
|
|
using osu.Game.Graphics.UserInterface;
|
|
using osu.Game.Resources.Localisation.Web;
|
|
|
|
namespace osu.Game.Overlays.Chat
|
|
{
|
|
public class ChatTextBox : FocusedTextBox
|
|
{
|
|
public readonly BindableBool ShowSearch = new BindableBool();
|
|
|
|
public override bool HandleLeftRightArrows => !ShowSearch.Value;
|
|
|
|
protected override bool ClearTextOnBackKey => false;
|
|
|
|
protected override void LoadComplete()
|
|
{
|
|
base.LoadComplete();
|
|
|
|
ShowSearch.BindValueChanged(change =>
|
|
{
|
|
bool showSearch = change.NewValue;
|
|
|
|
PlaceholderText = showSearch ? HomeStrings.SearchPlaceholder : ChatStrings.InputPlaceholder;
|
|
Text = string.Empty;
|
|
}, true);
|
|
}
|
|
|
|
protected override void Commit()
|
|
{
|
|
if (ShowSearch.Value)
|
|
return;
|
|
|
|
base.Commit();
|
|
}
|
|
}
|
|
}
|