From a2ef3aa21a5aec1565347af57be37e4564acb5f3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 10 Nov 2020 16:26:30 +0900 Subject: [PATCH 1/2] Force beatmap listing overlay's textbox back on screen when a key is pressed Not the cleanest solution, but works for now. Will eventually be replaced after the header is updated to reflect the latest designs (which keeps it on screen in all cases). Closes https://github.com/ppy/osu/issues/10703. --- .../BeatmapListingFilterControl.cs | 10 +++++++++- .../BeatmapListingSearchControl.cs | 19 +++++++++++++++++++ osu.Game/Overlays/BeatmapListingOverlay.cs | 7 +++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs b/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs index 3be38e3c1d..d991dcfcfb 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs @@ -32,6 +32,11 @@ namespace osu.Game.Overlays.BeatmapListing /// public Action SearchStarted; + /// + /// Any time the search text box receives key events (even while masked). + /// + public Action TypingStarted; + /// /// True when pagination has reached the end of available results. /// @@ -82,7 +87,10 @@ namespace osu.Game.Overlays.BeatmapListing Radius = 3, Offset = new Vector2(0f, 1f), }, - Child = searchControl = new BeatmapListingSearchControl(), + Child = searchControl = new BeatmapListingSearchControl + { + TypingStarted = () => TypingStarted?.Invoke() + } }, new Container { diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs b/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs index 3694c9855e..758781bb7d 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs @@ -1,12 +1,14 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osuTK; using osu.Framework.Bindables; +using osu.Framework.Input.Events; using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps; using osu.Game.Graphics.Containers; @@ -19,6 +21,11 @@ namespace osu.Game.Overlays.BeatmapListing { public class BeatmapListingSearchControl : CompositeDrawable { + /// + /// Any time the text box receives key events (even while masked). + /// + public Action TypingStarted; + public Bindable Query => textBox.Current; public Bindable Ruleset => modeFilter.Current; @@ -102,6 +109,7 @@ namespace osu.Game.Overlays.BeatmapListing textBox = new BeatmapSearchTextBox { RelativeSizeAxes = Axes.X, + TypingStarted = () => TypingStarted?.Invoke(), }, new ReverseChildIDFillFlowContainer { @@ -138,12 +146,23 @@ namespace osu.Game.Overlays.BeatmapListing private class BeatmapSearchTextBox : SearchTextBox { + /// + /// Any time the text box receives key events (even while masked). + /// + public Action TypingStarted; + protected override Color4 SelectionColour => Color4.Gray; public BeatmapSearchTextBox() { PlaceholderText = @"type in keywords..."; } + + protected override bool OnKeyDown(KeyDownEvent e) + { + TypingStarted?.Invoke(); + return base.OnKeyDown(e); + } } } } diff --git a/osu.Game/Overlays/BeatmapListingOverlay.cs b/osu.Game/Overlays/BeatmapListingOverlay.cs index 144af91145..1e29e713af 100644 --- a/osu.Game/Overlays/BeatmapListingOverlay.cs +++ b/osu.Game/Overlays/BeatmapListingOverlay.cs @@ -68,6 +68,7 @@ namespace osu.Game.Overlays Header, filterControl = new BeatmapListingFilterControl { + TypingStarted = onTypingStarted, SearchStarted = onSearchStarted, SearchFinished = onSearchFinished, }, @@ -102,6 +103,12 @@ namespace osu.Game.Overlays }; } + private void onTypingStarted() + { + // temporary until the textbox/header is updated to always stay on screen. + resultScrollContainer.ScrollToStart(); + } + protected override void OnFocus(FocusEvent e) { base.OnFocus(e); From 5221a34929719a84562ddafe8c24dc304a0cba90 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 10 Nov 2020 16:32:58 +0900 Subject: [PATCH 2/2] Only handle keys which create characters --- .../Overlays/BeatmapListing/BeatmapListingSearchControl.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs b/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs index 758781bb7d..e232bf045f 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs @@ -160,8 +160,11 @@ namespace osu.Game.Overlays.BeatmapListing protected override bool OnKeyDown(KeyDownEvent e) { + if (!base.OnKeyDown(e)) + return false; + TypingStarted?.Invoke(); - return base.OnKeyDown(e); + return true; } } }