1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Merge pull request #26178 from felipemarins/mod-search-text-box-select-all

Make mod search box text be selected when a new mod is selected/deselected
This commit is contained in:
Bartłomiej Dach 2024-01-15 20:08:02 +01:00 committed by GitHub
commit 40f612435d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -542,10 +542,23 @@ 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<SearchTextBox>().Single();
return textBox.SelectedText == textBox.Text;
});
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<SearchTextBox>().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);

View File

@ -48,6 +48,8 @@ namespace osu.Game.Graphics.UserInterface
public void KillFocus() => textBox.KillFocus();
public bool SelectAll() => textBox.SelectAll();
public ShearedSearchTextBox()
{
Height = 42;

View File

@ -719,7 +719,10 @@ namespace osu.Game.Overlays.Mods
ModState? firstMod = columnFlow.Columns.OfType<ModColumn>().FirstOrDefault(m => m.IsPresent)?.AvailableMods.FirstOrDefault(x => x.Visible);
if (firstMod is not null)
{
firstMod.Active.Value = !firstMod.Active.Value;
SearchTextBox.SelectAll();
}
return true;
}