1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 23:22:56 +08:00

Only clear text in FocusedTextBox

This commit is contained in:
Dean Herbert 2018-06-29 23:28:15 +09:00
parent 7c0547b4ee
commit fb90a4924b
2 changed files with 18 additions and 5 deletions

View File

@ -4,6 +4,7 @@
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Input; using osu.Framework.Input;
using System; using System;
using osu.Game.Input.Bindings;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
@ -18,6 +19,7 @@ namespace osu.Game.Graphics.UserInterface
public Action Exit; public Action Exit;
private bool focus; private bool focus;
public bool HoldFocus public bool HoldFocus
{ {
get { return focus; } get { return focus; }
@ -38,6 +40,20 @@ namespace osu.Game.Graphics.UserInterface
BorderThickness = 0; BorderThickness = 0;
} }
public override bool OnPressed(GlobalAction action)
{
if (action == GlobalAction.Back)
{
if (Text.Length > 0)
{
Text = string.Empty;
return true;
}
}
return base.OnPressed(action);
}
protected override void KillFocus() protected override void KillFocus()
{ {
base.KillFocus(); base.KillFocus();

View File

@ -59,14 +59,11 @@ namespace osu.Game.Graphics.UserInterface
protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), TextSize = CalculatedTextSize }; protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), TextSize = CalculatedTextSize };
public bool OnPressed(GlobalAction action) public virtual bool OnPressed(GlobalAction action)
{ {
if (action == GlobalAction.Back) if (action == GlobalAction.Back)
{ {
if (Text.Length > 0) KillFocus();
Text = string.Empty;
else
KillFocus();
return true; return true;
} }