Better SearchTextBox focus handling.

This commit is contained in:
Dean Herbert
2017-02-03 19:12:57 +09:00
parent 2ffab66184
commit ddea76927f
2 changed files with 20 additions and 10 deletions

View File

@ -61,13 +61,13 @@ namespace osu.Game.Screens.Select
public void Deactivate() public void Deactivate()
{ {
searchTextBox.GrabFocus = false; searchTextBox.HoldFocus = false;
searchTextBox.TriggerFocusLost(); searchTextBox.TriggerFocusLost();
} }
public void Activate() public void Activate()
{ {
searchTextBox.GrabFocus = true; searchTextBox.HoldFocus = true;
} }
private class TabItem : ClickableContainer private class TabItem : ClickableContainer

View File

@ -17,7 +17,18 @@ namespace osu.Game.Screens.Select
protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255); protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255);
protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255); protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255);
public Action Exit; public Action Exit;
public bool GrabFocus = false;
private bool focus;
public bool HoldFocus
{
get { return focus; }
set
{
focus = value;
if (!focus)
TriggerFocusLost();
}
}
private SpriteText placeholder; private SpriteText placeholder;
@ -64,8 +75,7 @@ namespace osu.Game.Screens.Select
protected override void Update() protected override void Update()
{ {
if (GrabFocus && !HasFocus && IsVisible) if (HoldFocus) RequestFocus();
TriggerFocus();
base.Update(); base.Update();
} }