mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 15:52:54 +08:00
Add hotkey for switching search bar focus
This commit is contained in:
parent
3ebc801484
commit
71e6f80c40
@ -546,16 +546,16 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestSearchFocusChange()
|
public void TestSearchFocusChangeViaClick()
|
||||||
{
|
{
|
||||||
createScreen();
|
createScreen();
|
||||||
|
|
||||||
AddStep("click on search", navigateAndClick<ShearedSearchTextBox>);
|
|
||||||
AddAssert("focused", () => modSelectOverlay.SearchTextBox.HasFocus);
|
|
||||||
|
|
||||||
AddStep("click on mod column", navigateAndClick<ModColumn>);
|
AddStep("click on mod column", navigateAndClick<ModColumn>);
|
||||||
AddAssert("lost focus", () => !modSelectOverlay.SearchTextBox.HasFocus);
|
AddAssert("lost focus", () => !modSelectOverlay.SearchTextBox.HasFocus);
|
||||||
|
|
||||||
|
AddStep("click on search", navigateAndClick<ShearedSearchTextBox>);
|
||||||
|
AddAssert("focused", () => modSelectOverlay.SearchTextBox.HasFocus);
|
||||||
|
|
||||||
void navigateAndClick<T>() where T : Drawable
|
void navigateAndClick<T>() where T : Drawable
|
||||||
{
|
{
|
||||||
InputManager.MoveMouseTo(modSelectOverlay.ChildrenOfType<T>().FirstOrDefault());
|
InputManager.MoveMouseTo(modSelectOverlay.ChildrenOfType<T>().FirstOrDefault());
|
||||||
@ -563,6 +563,20 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSearchFocusChangeViaKey()
|
||||||
|
{
|
||||||
|
createScreen();
|
||||||
|
|
||||||
|
const Key focus_switch_key = Key.Tab;
|
||||||
|
|
||||||
|
AddStep("press tab", () => InputManager.Key(focus_switch_key));
|
||||||
|
AddAssert("lost focus", () => !modSelectOverlay.SearchTextBox.HasFocus);
|
||||||
|
|
||||||
|
AddStep("press tab", () => InputManager.Key(focus_switch_key));
|
||||||
|
AddAssert("focused", () => modSelectOverlay.SearchTextBox.HasFocus);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDeselectAllViaKey()
|
public void TestDeselectAllViaKey()
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,7 @@ using osu.Game.Localisation;
|
|||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Mods
|
namespace osu.Game.Overlays.Mods
|
||||||
{
|
{
|
||||||
@ -684,6 +685,19 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
|
{
|
||||||
|
if (e.Repeat || e.Key != Key.Tab)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (SearchTextBox.HasFocus)
|
||||||
|
SearchTextBox.KillFocus();
|
||||||
|
else
|
||||||
|
SearchTextBox.TakeFocus();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Sample playback control
|
#region Sample playback control
|
||||||
|
Loading…
Reference in New Issue
Block a user