Merge pull request #18690 from frenzibyte/toolbar-block-scroll

Block scroll input from passing through game toolbar
This commit is contained in:
Dean Herbert
2022-06-15 02:23:28 +09:00
committed by GitHub
2 changed files with 27 additions and 2 deletions

View File

@ -6,11 +6,16 @@ using Moq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Testing;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays;
using osu.Game.Overlays.Toolbar;
using osu.Game.Rulesets;
using osuTK.Graphics;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Menus
@ -95,6 +100,28 @@ namespace osu.Game.Tests.Visual.Menus
AddAssert("toolbar is visible", () => toolbar.State.Value == Visibility.Visible);
}
[Test]
public void TestScrollInput()
{
OsuScrollContainer scroll = null;
AddStep("add scroll layer", () => Add(scroll = new OsuScrollContainer
{
Depth = 1f,
RelativeSizeAxes = Axes.Both,
Child = new Box
{
RelativeSizeAxes = Axes.X,
Height = DrawHeight * 2,
Colour = ColourInfo.GradientVertical(Color4.Gray, Color4.DarkGray),
}
}));
AddStep("hover toolbar", () => InputManager.MoveMouseTo(toolbar));
AddStep("perform scroll", () => InputManager.ScrollVerticalBy(500));
AddAssert("not scrolled", () => scroll.Current == 0);
}
public class TestToolbar : Toolbar
{
public new Bindable<OverlayActivation> OverlayActivationMode => base.OverlayActivationMode as Bindable<OverlayActivation>;

View File

@ -41,8 +41,6 @@ namespace osu.Game.Overlays.Toolbar
// Toolbar and its components need keyboard input even when hidden.
public override bool PropagateNonPositionalInputSubTree => true;
protected override bool BlockScrollInput => false;
public Toolbar()
{
RelativeSizeAxes = Axes.X;