From 7d8af5f1da4fd320c20b32ee5f76acf2d16e9bf6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 13:19:31 +0900 Subject: [PATCH] Use SearchTextBox Correctly handle focus. --- osu.Game/Overlays/OptionsOverlay.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index afe998c208..677c3f7c40 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -13,7 +13,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Options.Sections; -using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Select; namespace osu.Game.Overlays { @@ -33,7 +33,10 @@ public class OptionsOverlay : FocusedOverlayContainer private Sidebar sidebar; private SidebarButton[] sidebarButtons; private OptionsSection[] sections; + private SearchContainer searchContainer; + private SearchTextBox searchTextBox; + private float lastKnownScroll; public OptionsOverlay() @@ -45,8 +48,6 @@ public OptionsOverlay() [BackgroundDependencyLoader(permitNulls: true)] private void load(OsuGame game, OsuColour colours) { - OsuTextBox textBox; - sections = new OptionsSection[] { new GeneralSection(), @@ -96,11 +97,11 @@ private void load(OsuGame game, OsuColour colours) TextSize = 18, Margin = new MarginPadding { Left = CONTENT_MARGINS, Bottom = 30 }, }, - textBox = new OsuTextBox + searchTextBox = new SearchTextBox { - PlaceholderText = "Type to search!", Width = width - CONTENT_MARGINS * 2, Margin = new MarginPadding { Left = CONTENT_MARGINS }, + Exit = () => Hide(), }, searchContainer = new SearchContainer { @@ -128,7 +129,7 @@ private void load(OsuGame game, OsuColour colours) } }; - textBox.Current.ValueChanged += newValue => searchContainer.SearchTerm = newValue; + searchTextBox.Current.ValueChanged += newValue => searchContainer.SearchTerm = newValue; scrollContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 }; } @@ -169,6 +170,8 @@ protected override void PopIn() scrollContainer.MoveToX(0, TRANSITION_LENGTH, EasingTypes.OutQuint); sidebar.MoveToX(0, TRANSITION_LENGTH, EasingTypes.OutQuint); FadeTo(1, TRANSITION_LENGTH / 2); + + searchTextBox.HoldFocus = true; } protected override void PopOut() @@ -178,6 +181,9 @@ protected override void PopOut() scrollContainer.MoveToX(-width, TRANSITION_LENGTH, EasingTypes.OutQuint); sidebar.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, EasingTypes.OutQuint); FadeTo(0, TRANSITION_LENGTH / 2); + + searchTextBox.HoldFocus = false; + searchTextBox.TriggerFocusLost(); } } }