From cbfcda79299e2ed2d42e720b81dcf6cd6f55984f Mon Sep 17 00:00:00 2001 From: Felipe Marins Date: Thu, 28 Dec 2023 00:10:01 -0300 Subject: [PATCH 1/6] Expose `SelectAll()` method on `ShearedSearchTextBox` --- osu.Game/Graphics/UserInterface/ShearedSearchTextBox.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Graphics/UserInterface/ShearedSearchTextBox.cs b/osu.Game/Graphics/UserInterface/ShearedSearchTextBox.cs index 131041e706..c3a9f8a586 100644 --- a/osu.Game/Graphics/UserInterface/ShearedSearchTextBox.cs +++ b/osu.Game/Graphics/UserInterface/ShearedSearchTextBox.cs @@ -48,6 +48,8 @@ namespace osu.Game.Graphics.UserInterface public void KillFocus() => textBox.KillFocus(); + public bool SelectAll() => textBox.SelectAll(); + public ShearedSearchTextBox() { Height = 42; From dce9204731972d81aaeedb42002de243b9c0742c Mon Sep 17 00:00:00 2001 From: Felipe Marins Date: Thu, 28 Dec 2023 00:10:44 -0300 Subject: [PATCH 2/6] Select search box text on ModSelectOverlay when mod selection changes --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index baa7e594c1..43f44d682d 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -565,6 +565,9 @@ namespace osu.Game.Overlays.Mods .ToArray(); SelectedMods.Value = ComputeNewModsFromSelection(SelectedMods.Value, candidateSelection); + + if (SearchTextBox.HasFocus) + SearchTextBox.SelectAll(); } #region Transition handling From d8962ddff8e75a23114266db68de5f6e54eac264 Mon Sep 17 00:00:00 2001 From: Felipe Marins Date: Mon, 15 Jan 2024 03:22:52 -0300 Subject: [PATCH 3/6] Select all when pressing enter instead of every mod selection change --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 43f44d682d..8cb990757f 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -565,9 +565,6 @@ namespace osu.Game.Overlays.Mods .ToArray(); SelectedMods.Value = ComputeNewModsFromSelection(SelectedMods.Value, candidateSelection); - - if (SearchTextBox.HasFocus) - SearchTextBox.SelectAll(); } #region Transition handling @@ -724,6 +721,8 @@ namespace osu.Game.Overlays.Mods if (firstMod is not null) firstMod.Active.Value = !firstMod.Active.Value; + SearchTextBox.SelectAll(); + return true; } } From e8394e6f74351f7b136fe16d2a53033814d1bd56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 15 Jan 2024 19:05:33 +0100 Subject: [PATCH 4/6] Add test coverage --- .../Visual/UserInterface/TestSceneModSelectOverlay.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs index 4b101a52f4..7958b68fb5 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs @@ -542,6 +542,11 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("press enter", () => InputManager.Key(Key.Enter)); AddAssert("hidden selected", () => getPanelForMod(typeof(OsuModHidden)).Active.Value); + AddAssert("all text selected in textbox", () => + { + var textBox = modSelectOverlay.ChildrenOfType().Single(); + return textBox.SelectedText == textBox.Text; + }); AddStep("press enter again", () => InputManager.Key(Key.Enter)); AddAssert("hidden deselected", () => !getPanelForMod(typeof(OsuModHidden)).Active.Value); From c0d4ed4789fbd7de96c131e2e7882ac673d03e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 15 Jan 2024 19:07:52 +0100 Subject: [PATCH 5/6] Add test coverage of select-all-text-in-search when nothing matched --- .../Visual/UserInterface/TestSceneModSelectOverlay.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs index 7958b68fb5..046954db47 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs @@ -551,6 +551,14 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("press enter again", () => InputManager.Key(Key.Enter)); AddAssert("hidden deselected", () => !getPanelForMod(typeof(OsuModHidden)).Active.Value); + AddStep("apply search matching nothing", () => modSelectOverlay.SearchTerm = "ZZZ"); + AddStep("press enter", () => InputManager.Key(Key.Enter)); + AddAssert("all text not selected in textbox", () => + { + var textBox = modSelectOverlay.ChildrenOfType().Single(); + return textBox.SelectedText != textBox.Text; + }); + AddStep("clear search", () => modSelectOverlay.SearchTerm = string.Empty); AddStep("press enter", () => InputManager.Key(Key.Enter)); AddAssert("mod select hidden", () => modSelectOverlay.State.Value == Visibility.Hidden); From c46615839dcc40bca80f401d8559422492c43cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 15 Jan 2024 19:09:50 +0100 Subject: [PATCH 6/6] Only select all text in mod search text box if enter press selected anything --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 8cb990757f..a774bb9167 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -719,9 +719,10 @@ namespace osu.Game.Overlays.Mods ModState? firstMod = columnFlow.Columns.OfType().FirstOrDefault(m => m.IsPresent)?.AvailableMods.FirstOrDefault(x => x.Visible); if (firstMod is not null) + { firstMod.Active.Value = !firstMod.Active.Value; - - SearchTextBox.SelectAll(); + SearchTextBox.SelectAll(); + } return true; }