Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix disabling hold-to-right-click not cancelling in-progress actions #6459

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions osu.Framework.Tests/Visual/Input/TestSceneTouchInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public partial class TestSceneTouchInput : ManualInputManagerTestScene
[SetUp]
public new void SetUp() => Schedule(() =>
{
InputManager.RightClickFromLongTouch = true;

Children = new Drawable[]
{
new Container
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions osu.Framework/Input/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@ protected override void Update()
if (FocusedDrawable == null)
focusTopMostRequestingDrawable();

if (!AllowRightClickFromLongTouch && touchLongPressDelegate != null)
cancelTouchLongPress();

base.Update();
}

Expand Down
Loading