mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 16:13:34 +08:00
Merge pull request #27780 from mafarrica/27105-fix-mod-search-box-focus-changes
Fix mod search box not tracking external changes to focus state
This commit is contained in:
commit
1344ca4e19
@ -612,6 +612,23 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddAssert("search text box unfocused", () => !modSelectOverlay.SearchTextBox.HasFocus);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSearchBoxFocusToggleRespondsToExternalChanges()
|
||||
{
|
||||
AddStep("text search does not start active", () => configManager.SetValue(OsuSetting.ModSelectTextSearchStartsActive, false));
|
||||
createScreen();
|
||||
|
||||
AddUntilStep("search text box not focused", () => !modSelectOverlay.SearchTextBox.HasFocus);
|
||||
|
||||
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||
AddAssert("search text box focused", () => modSelectOverlay.SearchTextBox.HasFocus);
|
||||
|
||||
AddStep("unfocus search text box externally", () => InputManager.ChangeFocus(null));
|
||||
|
||||
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||
AddAssert("search text box focused", () => modSelectOverlay.SearchTextBox.HasFocus);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTextSearchDoesNotBlockCustomisationPanelKeyboardInteractions()
|
||||
{
|
||||
|
@ -143,8 +143,6 @@ namespace osu.Game.Overlays.Mods
|
||||
protected ShearedToggleButton? CustomisationButton { get; private set; }
|
||||
protected SelectAllModsButton? SelectAllModsButton { get; set; }
|
||||
|
||||
private bool textBoxShouldFocus;
|
||||
|
||||
private Sample? columnAppearSample;
|
||||
|
||||
private WorkingBeatmap? beatmap;
|
||||
@ -542,7 +540,7 @@ namespace osu.Game.Overlays.Mods
|
||||
if (customisationVisible.Value)
|
||||
SearchTextBox.KillFocus();
|
||||
else
|
||||
setTextBoxFocus(textBoxShouldFocus);
|
||||
setTextBoxFocus(textSearchStartsActive.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -798,15 +796,13 @@ namespace osu.Game.Overlays.Mods
|
||||
return false;
|
||||
|
||||
// TODO: should probably eventually support typical platform search shortcuts (`Ctrl-F`, `/`)
|
||||
setTextBoxFocus(!textBoxShouldFocus);
|
||||
setTextBoxFocus(!SearchTextBox.HasFocus);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setTextBoxFocus(bool keepFocus)
|
||||
private void setTextBoxFocus(bool focus)
|
||||
{
|
||||
textBoxShouldFocus = keepFocus;
|
||||
|
||||
if (textBoxShouldFocus)
|
||||
if (focus)
|
||||
SearchTextBox.TakeFocus();
|
||||
else
|
||||
SearchTextBox.KillFocus();
|
||||
|
Loading…
Reference in New Issue
Block a user