diff --git a/osu.Framework.Tests/Visual/Input/TestSceneTouchInput.cs b/osu.Framework.Tests/Visual/Input/TestSceneTouchInput.cs index bcd61179c7..6e1e91d198 100644 --- a/osu.Framework.Tests/Visual/Input/TestSceneTouchInput.cs +++ b/osu.Framework.Tests/Visual/Input/TestSceneTouchInput.cs @@ -32,6 +32,8 @@ public partial class TestSceneTouchInput : ManualInputManagerTestScene [SetUp] public new void SetUp() => Schedule(() => { + InputManager.RightClickFromLongTouch = true; + Children = new Drawable[] { new Container @@ -606,6 +608,25 @@ public void TestHoldTwoTouchesAndReleaseSecondBeforeRightClick() AddAssert("no right click received", () => primaryReceptor.MouseEvents.Count == 0 && secondaryReceptor.MouseEvents.Count == 0); } + [Test] + public void TestHoldTouchAndDisableHoldingBeforeRightClick() + { + InputReceptor primaryReceptor = null; + + AddStep("retrieve primary receptor", () => primaryReceptor = receptors[(int)TouchSource.Touch1]); + AddStep("setup handlers to receive mouse-from-touch", () => + { + primaryReceptor.HandleTouch = _ => false; + primaryReceptor.HandleMouse = e => e is MouseButtonEvent button && button.Button == MouseButton.Right; + }); + + AddStep("begin touch", () => InputManager.BeginTouch(new Touch(TouchSource.Touch1, getTouchDownPos(TouchSource.Touch1)))); + AddWaitStep("hold shortly", 2); + AddStep("turn off hold-to-right-click", () => InputManager.RightClickFromLongTouch = false); + AddWaitStep("wait a bit", 4); + AddAssert("no right click received", () => primaryReceptor.MouseEvents.Count == 0); + } + private partial class InputReceptor : Container { public readonly TouchSource AssociatedSource; diff --git a/osu.Framework/Input/InputManager.cs b/osu.Framework/Input/InputManager.cs index debc7cef14..825bb5822e 100644 --- a/osu.Framework/Input/InputManager.cs +++ b/osu.Framework/Input/InputManager.cs @@ -507,6 +507,9 @@ protected override void Update() if (FocusedDrawable == null) focusTopMostRequestingDrawable(); + if (!AllowRightClickFromLongTouch && touchLongPressDelegate != null) + cancelTouchLongPress(); + base.Update(); }