Skip to content
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
2 changes: 1 addition & 1 deletion src/Controls/src/Core/TapGestureRecognizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal void SendTapped(View sender, Func<IElement?, Point?>? getPosition = nul
if (cmd != null && cmd.CanExecute(CommandParameter))
cmd.Execute(CommandParameter);

Tapped?.Invoke(sender, new TappedEventArgs(CommandParameter, getPosition));
Tapped?.Invoke(sender, new TappedEventArgs(CommandParameter, getPosition, Buttons));
}

}
Expand Down
3 changes: 2 additions & 1 deletion src/Controls/src/Core/TappedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ public TappedEventArgs(object? parameter)
Parameter = parameter;
}

internal TappedEventArgs(object? parameter, Func<IElement?, Point?>? getPosition) : this(parameter)
internal TappedEventArgs(object? parameter, Func<IElement?, Point?>? getPosition, ButtonsMask buttons) : this(parameter)
{
_getPosition = getPosition;
Buttons = buttons;
}

/// <include file="../../docs/Microsoft.Maui.Controls/TappedEventArgs.xml" path="//Member[@MemberName='Parameter']/Docs/*" />
Expand Down
37 changes: 37 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24734.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 24734, "TapGestureRecognizer ButtonMask always return 0", PlatformAffected.All)]
public class Issue24734 : ContentPage
{
public Issue24734()
{
VerticalStackLayout stackLayout = new VerticalStackLayout
{
Spacing = 20,
Padding = new Thickness(20)
};

Label label = new Label
{
Text = "Failure",
AutomationId = "LabelwithGesture",
};

TapGestureRecognizer tapGestureRecognizer = new TapGestureRecognizer
{
Buttons = ButtonsMask.Primary
};

tapGestureRecognizer.Tapped += (sender, e) =>
{
if (e.Buttons == ButtonsMask.Primary)
{
label.Text = "Success";
}
};

label.GestureRecognizers.Add(tapGestureRecognizer);
stackLayout.Add(label);
Content = stackLayout;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue24734 : _IssuesUITest
{
public Issue24734(TestDevice device) : base(device)
{
}

public override string Issue => "TapGestureRecognizer ButtonMask always return 0";

[Test]
[Category(UITestCategories.Gestures)]
public void ButtonMaskShouldNotReturnZero()
{
App.WaitForElement("LabelwithGesture");
App.Tap("LabelwithGesture");
App.WaitForElement("Success");
}
}
Loading