From 49974dc83258249438b2a89fa92d562132f4a535 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 19 Jul 2024 15:16:30 +0300 Subject: [PATCH 1/2] Add failing test case --- .../Input/TestScenePassThroughInputManager.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/osu.Framework.Tests/Visual/Input/TestScenePassThroughInputManager.cs b/osu.Framework.Tests/Visual/Input/TestScenePassThroughInputManager.cs index 6b52dd0ec4..eada274af3 100644 --- a/osu.Framework.Tests/Visual/Input/TestScenePassThroughInputManager.cs +++ b/osu.Framework.Tests/Visual/Input/TestScenePassThroughInputManager.cs @@ -121,6 +121,19 @@ public void TestKeyInput() AddAssert("key released", () => !testInputManager.CurrentState.Keyboard.Keys.HasAnyButtonPressed); } + [Test] + public void TestPressKeyThenReleaseWhileDisabled() + { + addTestInputManagerStep(); + AddStep("press key", () => InputManager.PressKey(Key.A)); + AddStep("UseParentInput = false", () => testInputManager.UseParentInput = false); + AddStep("release key", () => InputManager.ReleaseKey(Key.A)); + AddStep("press key again", () => InputManager.PressKey(Key.A)); + AddStep("UseParentInput = true", () => testInputManager.UseParentInput = true); + AddStep("release key", () => InputManager.ReleaseKey(Key.A)); + AddAssert("key released", () => !testInputManager.CurrentState.Keyboard.Keys.HasAnyButtonPressed); + } + [Test] public void TestTouchInput() { From b9a47a057e30b8eaf2cf7a7bb55adfb71d86305b Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 19 Jul 2024 15:18:00 +0300 Subject: [PATCH 2/2] Keep `PassThroughInputManager` in input queue even while parent input is disabled --- .../Input/TestScenePassThroughInputManager.cs | 40 ------------------- .../Input/PassThroughInputManager.cs | 3 -- 2 files changed, 43 deletions(-) diff --git a/osu.Framework.Tests/Visual/Input/TestScenePassThroughInputManager.cs b/osu.Framework.Tests/Visual/Input/TestScenePassThroughInputManager.cs index eada274af3..a6bf4f748a 100644 --- a/osu.Framework.Tests/Visual/Input/TestScenePassThroughInputManager.cs +++ b/osu.Framework.Tests/Visual/Input/TestScenePassThroughInputManager.cs @@ -253,46 +253,6 @@ public void TestMouseTouchProductionOnPassThrough() AddAssert("pass-through handled mouse", () => testInputManager.CurrentState.Mouse.Buttons.Single() == MouseButton.Left); } - /// - /// Ensures that does not handle input within the frame that is enabled. - /// - [Test] - public void TestInputPropagation() - { - addTestInputManagerStep(); - AddStep("setup hierarchy", () => - { - Add(new HandlingBox - { - Alpha = 0.5f, - RelativeSizeAxes = Axes.Both, - OnHandle = e => - { - if (e is KeyDownEvent keyDown && !keyDown.Repeat) - testInputManager.UseParentInput = true; - - return false; - } - }); - }); - - AddStep("turn off parent input", () => testInputManager.UseParentInput = false); - AddStep("press key", () => InputManager.PressKey(Key.A)); - AddAssert("key not pressed in pass-through", () => !keyboard.IsPressed(Key.A)); - AddAssert("no key down event inside pass-through", () => testInputManager.Status.KeyDownCount == 0); - - // parent input should be turned on by the box handler above. - AddAssert("parent input turned on", () => testInputManager.UseParentInput); - AddStep("release key", () => InputManager.ReleaseKey(Key.A)); - - AddStep("press key", () => InputManager.PressKey(Key.A)); - AddStep("turn off parent input", () => testInputManager.UseParentInput = false); - AddAssert("key pressed in pass-through", () => keyboard.IsPressed(Key.A)); - - AddStep("release key", () => InputManager.ReleaseKey(Key.A)); - AddAssert("key still pressed in pass-through", () => keyboard.IsPressed(Key.A)); - } - public partial class TestInputManager : ManualInputManager { public readonly TestSceneInputManager.ContainingInputManagerStatusText Status; diff --git a/osu.Framework/Input/PassThroughInputManager.cs b/osu.Framework/Input/PassThroughInputManager.cs index d48ab8e23a..587993ad9a 100644 --- a/osu.Framework/Input/PassThroughInputManager.cs +++ b/osu.Framework/Input/PassThroughInputManager.cs @@ -57,9 +57,6 @@ protected override void LoadComplete() parentInputManager = GetContainingInputManager(); } - public override bool PropagateNonPositionalInputSubTree => UseParentInput; - public override bool PropagatePositionalInputSubTree => UseParentInput; - public override bool HandleHoverEvents => parentInputManager != null && UseParentInput ? parentInputManager.HandleHoverEvents : base.HandleHoverEvents; internal override bool BuildNonPositionalInputQueue(List queue, bool allowBlocking = true)