Skip to content

TapGestureRecognizer ButtonMask always return 0. #24734

@TobiasJoergensen

Description

@TobiasJoergensen

Description

I need to be able to detect a right click on a MAUI application. I have been following the example supplied by the documentation Define the button mask. When I try to debug the example provided in the steps to reproduce, it always return 0 in the Buttons property of the event args.

Steps to Reproduce

Create a view with following XAML:

<Label Text="Some title">
    <Label.GestureRecognizers>
        <TapGestureRecognizer Tapped="OnTapGestureRecognizerTapped" Buttons="Primary,Secondary" />
    </Label.GestureRecognizers>
</Label>

Then in the code behind file, intercept the event with the following:

private void OnTapGestureRecognizerTapped(object sender, TappedEventArgs e)
{
}

Link to public reproduction project repository

No response

Version with bug

8.0.80 SR8

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows 11

Did you find any workaround?

My current requirement is that I need to show a context menu based on a right click. It seems that adding a context menu to my DataTemplate is a workaround. So in short, the context menu correctly intercepts a right click.

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions