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:
commit
40f612435d
@ -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);
|
||||
|
@ -48,6 +48,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public void KillFocus() => textBox.KillFocus();
|
||||
|
||||
public bool SelectAll() => textBox.SelectAll();
|
||||
|
||||
public ShearedSearchTextBox()
|
||||
{
|
||||
Height = 42;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user