1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 22:06:08 +08:00

Fix focus interactions with search text box

This commit is contained in:
Drew DeVault 2017-01-30 13:43:21 -05:00
parent 09680196c9
commit 144a87a247
3 changed files with 29 additions and 3 deletions

View File

@ -56,6 +56,17 @@ namespace osu.Game.Screens.Select
}; };
} }
public void Deactivate()
{
searchTextBox.GrabFocus = false;
searchTextBox.TriggerFocusLost();
}
public void Activate()
{
searchTextBox.GrabFocus = true;
}
private class TabItem : ClickableContainer private class TabItem : ClickableContainer
{ {
public string Text public string Text

View File

@ -242,6 +242,8 @@ namespace osu.Game.Screens.Select
beatmapInfoWedge.MoveToX(wedged_container_start_position.X - 50); beatmapInfoWedge.MoveToX(wedged_container_start_position.X - 50);
beatmapInfoWedge.MoveToX(wedged_container_start_position.X, 800, EasingTypes.OutQuint); beatmapInfoWedge.MoveToX(wedged_container_start_position.X, 800, EasingTypes.OutQuint);
filter.Activate();
} }
protected override void OnResuming(GameMode last) protected override void OnResuming(GameMode last)
@ -255,6 +257,8 @@ namespace osu.Game.Screens.Select
Content.FadeIn(250); Content.FadeIn(250);
Content.ScaleTo(1, 250, EasingTypes.OutSine); Content.ScaleTo(1, 250, EasingTypes.OutSine);
filter.Activate();
} }
protected override void OnSuspending(GameMode next) protected override void OnSuspending(GameMode next)
@ -262,6 +266,8 @@ namespace osu.Game.Screens.Select
Content.ScaleTo(1.1f, 250, EasingTypes.InSine); Content.ScaleTo(1.1f, 250, EasingTypes.InSine);
Content.FadeOut(250); Content.FadeOut(250);
filter.Deactivate();
base.OnSuspending(next); base.OnSuspending(next);
} }
@ -271,6 +277,8 @@ namespace osu.Game.Screens.Select
beatmapInfoWedge.RotateTo(10, 800, EasingTypes.InQuint); beatmapInfoWedge.RotateTo(10, 800, EasingTypes.InQuint);
Content.FadeOut(100); Content.FadeOut(100);
filter.Deactivate();
return base.OnExiting(next); return base.OnExiting(next);
} }

View File

@ -15,7 +15,7 @@ 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 override bool HasFocus => true; public bool GrabFocus = false;
private SpriteText placeholder; private SpriteText placeholder;
@ -63,12 +63,19 @@ namespace osu.Game.Screens.Select
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
OnFocus(null); }
protected override void Update()
{
if (GrabFocus && !HasFocus && IsVisible)
TriggerFocus();
base.Update();
} }
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{ {
if (args.Key == Key.Left || args.Key == Key.Right || args.Key == Key.Enter) if (args.Key == Key.Left || args.Key == Key.Right
|| args.Key == Key.Enter || args.Key == Key.Escape)
return false; return false;
return base.OnKeyDown(state, args); return base.OnKeyDown(state, args);
} }