mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 09:02:55 +08:00
Merge pull request #18737 from frenzibyte/fix-up-down
Fix toolbar music button handling keys while not hovered
This commit is contained in:
commit
b74bb83176
@ -17,6 +17,7 @@ using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Overlays.Toolbar;
|
||||
using osu.Game.Rulesets;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
|
||||
@ -153,11 +154,23 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
AddStep("hover toolbar music button", () => InputManager.MoveMouseTo(this.ChildrenOfType<ToolbarMusicButton>().Single()));
|
||||
|
||||
AddStep("reset volume", () => Audio.Volume.Value = 1);
|
||||
AddStep("hide volume overlay", () => volumeOverlay.Hide());
|
||||
|
||||
AddRepeatStep("scroll down", () => InputManager.ScrollVerticalBy(-10), 5);
|
||||
AddAssert("volume lowered down", () => Audio.Volume.Value < 1);
|
||||
AddRepeatStep("scroll up", () => InputManager.ScrollVerticalBy(10), 5);
|
||||
AddAssert("volume raised up", () => Audio.Volume.Value == 1);
|
||||
|
||||
AddStep("move mouse away", () => InputManager.MoveMouseTo(Vector2.Zero));
|
||||
AddAssert("button not hovered", () => !this.ChildrenOfType<ToolbarMusicButton>().Single().IsHovered);
|
||||
|
||||
AddStep("set volume to 0.5", () => Audio.Volume.Value = 0.5);
|
||||
AddStep("hide volume overlay", () => volumeOverlay.Hide());
|
||||
|
||||
AddRepeatStep("scroll down", () => InputManager.ScrollVerticalBy(-10), 5);
|
||||
AddAssert("volume not changed", () => Audio.Volume.Value == 0.5);
|
||||
AddRepeatStep("scroll up", () => InputManager.ScrollVerticalBy(10), 5);
|
||||
AddAssert("volume not changed", () => Audio.Volume.Value == 0.5);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -166,11 +179,24 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
AddStep("hover toolbar music button", () => InputManager.MoveMouseTo(this.ChildrenOfType<ToolbarMusicButton>().Single()));
|
||||
|
||||
AddStep("reset volume", () => Audio.Volume.Value = 1);
|
||||
AddStep("hide volume overlay", () => volumeOverlay.Hide());
|
||||
|
||||
AddRepeatStep("arrow down", () => InputManager.Key(Key.Down), 5);
|
||||
AddAssert("volume lowered down", () => Audio.Volume.Value < 1);
|
||||
AddRepeatStep("arrow up", () => InputManager.Key(Key.Up), 5);
|
||||
AddAssert("volume raised up", () => Audio.Volume.Value == 1);
|
||||
|
||||
AddStep("hide volume overlay", () => volumeOverlay.Hide());
|
||||
AddStep("move mouse away", () => InputManager.MoveMouseTo(Vector2.Zero));
|
||||
AddAssert("button not hovered", () => !this.ChildrenOfType<ToolbarMusicButton>().Single().IsHovered);
|
||||
|
||||
AddStep("set volume", () => Audio.Volume.Value = 0.5);
|
||||
AddStep("hide volume overlay", () => volumeOverlay.Hide());
|
||||
|
||||
AddRepeatStep("arrow down", () => InputManager.Key(Key.Down), 5);
|
||||
AddAssert("volume not changed", () => Audio.Volume.Value == 0.5);
|
||||
AddRepeatStep("arrow up", () => InputManager.Key(Key.Up), 5);
|
||||
AddAssert("volume not changed", () => Audio.Volume.Value == 0.5);
|
||||
}
|
||||
|
||||
public class TestToolbar : Toolbar
|
||||
|
@ -81,6 +81,9 @@ namespace osu.Game.Overlays.Toolbar
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (!IsHovered)
|
||||
return false;
|
||||
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Up:
|
||||
|
Loading…
Reference in New Issue
Block a user