1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 18:03:11 +08:00

Merge pull request #25857 from peppy/fix-mod-settings-keyboard-adjust

Fix mod search textbox having focus while settings are visible
This commit is contained in:
Bartłomiej Dach 2023-12-19 15:44:17 +01:00 committed by GitHub
commit 64b0534fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 9 deletions

View File

@ -572,7 +572,7 @@ namespace osu.Game.Tests.Visual.UserInterface
[Test] [Test]
public void TestTextSearchActiveByDefault() public void TestTextSearchActiveByDefault()
{ {
configManager.SetValue(OsuSetting.ModSelectTextSearchStartsActive, true); AddStep("text search starts active", () => configManager.SetValue(OsuSetting.ModSelectTextSearchStartsActive, true));
createScreen(); createScreen();
AddUntilStep("search text box focused", () => modSelectOverlay.SearchTextBox.HasFocus); AddUntilStep("search text box focused", () => modSelectOverlay.SearchTextBox.HasFocus);
@ -587,7 +587,7 @@ namespace osu.Game.Tests.Visual.UserInterface
[Test] [Test]
public void TestTextSearchNotActiveByDefault() public void TestTextSearchNotActiveByDefault()
{ {
configManager.SetValue(OsuSetting.ModSelectTextSearchStartsActive, false); AddStep("text search does not start active", () => configManager.SetValue(OsuSetting.ModSelectTextSearchStartsActive, false));
createScreen(); createScreen();
AddUntilStep("search text box not focused", () => !modSelectOverlay.SearchTextBox.HasFocus); AddUntilStep("search text box not focused", () => !modSelectOverlay.SearchTextBox.HasFocus);
@ -599,6 +599,31 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert("search text box unfocused", () => !modSelectOverlay.SearchTextBox.HasFocus); AddAssert("search text box unfocused", () => !modSelectOverlay.SearchTextBox.HasFocus);
} }
[Test]
public void TestTextSearchDoesNotBlockCustomisationPanelKeyboardInteractions()
{
AddStep("text search starts active", () => configManager.SetValue(OsuSetting.ModSelectTextSearchStartsActive, true));
createScreen();
AddUntilStep("search text box focused", () => modSelectOverlay.SearchTextBox.HasFocus);
AddStep("select DT", () => SelectedMods.Value = new Mod[] { new OsuModDoubleTime() });
AddAssert("DT selected", () => modSelectOverlay.ChildrenOfType<ModPanel>().Count(panel => panel.Active.Value), () => Is.EqualTo(1));
AddStep("open customisation area", () => modSelectOverlay.CustomisationButton!.TriggerClick());
assertCustomisationToggleState(false, true);
AddStep("hover over mod settings slider", () =>
{
var slider = modSelectOverlay.ChildrenOfType<ModSettingsArea>().Single().ChildrenOfType<OsuSliderBar<double>>().First();
InputManager.MoveMouseTo(slider);
});
AddStep("press right arrow", () => InputManager.PressKey(Key.Right));
AddAssert("DT speed changed", () => !SelectedMods.Value.OfType<OsuModDoubleTime>().Single().SpeedChange.IsDefault);
AddStep("close customisation area", () => InputManager.PressKey(Key.Escape));
AddUntilStep("search text box reacquired focus", () => modSelectOverlay.SearchTextBox.HasFocus);
}
[Test] [Test]
public void TestDeselectAllViaKey() public void TestDeselectAllViaKey()
{ {

View File

@ -132,6 +132,8 @@ namespace osu.Game.Overlays.Mods
protected ShearedToggleButton? CustomisationButton { get; private set; } protected ShearedToggleButton? CustomisationButton { get; private set; }
protected SelectAllModsButton? SelectAllModsButton { get; set; } protected SelectAllModsButton? SelectAllModsButton { get; set; }
private bool textBoxShouldFocus;
private Sample? columnAppearSample; private Sample? columnAppearSample;
private WorkingBeatmap? beatmap; private WorkingBeatmap? beatmap;
@ -508,6 +510,11 @@ namespace osu.Game.Overlays.Mods
modSettingsArea.ResizeHeightTo(modAreaHeight, transition_duration, Easing.InOutCubic); modSettingsArea.ResizeHeightTo(modAreaHeight, transition_duration, Easing.InOutCubic);
TopLevelContent.MoveToY(-modAreaHeight, transition_duration, Easing.InOutCubic); TopLevelContent.MoveToY(-modAreaHeight, transition_duration, Easing.InOutCubic);
if (customisationVisible.Value)
SearchTextBox.KillFocus();
else
setTextBoxFocus(textBoxShouldFocus);
} }
/// <summary> /// <summary>
@ -621,8 +628,7 @@ namespace osu.Game.Overlays.Mods
nonFilteredColumnCount += 1; nonFilteredColumnCount += 1;
} }
if (textSearchStartsActive.Value) setTextBoxFocus(textSearchStartsActive.Value);
SearchTextBox.TakeFocus();
} }
protected override void PopOut() protected override void PopOut()
@ -761,14 +767,20 @@ namespace osu.Game.Overlays.Mods
return false; return false;
// TODO: should probably eventually support typical platform search shortcuts (`Ctrl-F`, `/`) // TODO: should probably eventually support typical platform search shortcuts (`Ctrl-F`, `/`)
if (SearchTextBox.HasFocus) setTextBoxFocus(!textBoxShouldFocus);
SearchTextBox.KillFocus();
else
SearchTextBox.TakeFocus();
return true; return true;
} }
private void setTextBoxFocus(bool keepFocus)
{
textBoxShouldFocus = keepFocus;
if (textBoxShouldFocus)
SearchTextBox.TakeFocus();
else
SearchTextBox.KillFocus();
}
#endregion #endregion
#region Sample playback control #region Sample playback control

View File

@ -32,6 +32,8 @@ namespace osu.Game.Overlays.Mods
[Resolved] [Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!; private OverlayColourProvider colourProvider { get; set; } = null!;
public override bool AcceptsFocus => true;
public ModSettingsArea() public ModSettingsArea()
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;