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

PointerGestureRecognizer Does Not Work on Android #20849

Open
owaits opened this issue Feb 26, 2024 · 9 comments · May be fixed by #22109
Open

PointerGestureRecognizer Does Not Work on Android #20849

owaits opened this issue Feb 26, 2024 · 9 comments · May be fixed by #22109
Labels
area-gestures Gesture types platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@owaits
Copy link

owaits commented Feb 26, 2024

Description

I am not able to get the PointerPressed event of PointerGestureRecognizer to work on Android. A brief look at the code would suggest its not even been implemented. I was trying to achieve a long press and managed to get this to work on Windows but on Android it does not work. After going round in a few circles it appears this just does not work on Android but I can find very little info to confirm this. The original task to implement Pointer gestures seems to not include an Android implemtation.

Steps to Reproduce

  1. Create New Maui App
  2. Modify the code as bellow:
<Label
    Text="Hello, World!"
    Style="{StaticResource Headline}"
    SemanticProperties.HeadingLevel="Level1" >
    <Label.GestureRecognizers>
        <PointerGestureRecognizer PointerPressed="PointerGestureRecognizer_PointerPressed" />
    </Label.GestureRecognizers>
</Label>
      private void PointerGestureRecognizer_PointerPressed(object sender, PointerEventArgs e)
      {
          count++;

          if (count == 1)
              CounterBtn.Text = $"Clicked {count} time";
          else
              CounterBtn.Text = $"Clicked {count} times";
      }
  1. Run on Android and press the Hello World label, the counter is not incremented but on Windows and IOS it is.

Link to public reproduction project repository

No response

Version with bug

8.0.3 GA

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No

Relevant log output

No response

@owaits owaits added the t/bug Something isn't working label Feb 26, 2024
@jsuarezruiz jsuarezruiz added the area-gestures Gesture types label Feb 27, 2024
@MartinRusk
Copy link

MartinRusk commented Mar 4, 2024

I can confirm - PointerGestureRecognizer works on Windows but not on Android in 8.0.6. High relevance as this is a long awaited and urgently needed feature.

@Antoniy2000
Copy link

Same - not only PointerPressed, but other methods doesnt seem to work neither on Android nor on Emulator

@flipper09112
Copy link

flipper09112 commented Mar 13, 2024

Same here. PointerExit in android for me doesnt work too

Version 8.0.10

@jaosnz-rep
Copy link

Verified on 17.10.0 Preview 2.0, can use the code to repro the error on Android platforms with .NET Maui app.

@jaosnz-rep jaosnz-rep added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Mar 19, 2024
@mrmrmystery
Copy link

Also having this issue. However I noticed that pointer enter, exit and move events fire when I hover the element with a stylus but not when the stylus is touching the screen.

@Odaronil
Copy link

Odaronil commented May 4, 2024

The problem is still there. Maui 8.0.7-8.0.21, Visual studio 17.9.6

@jsuarezruiz jsuarezruiz added this to the Backlog milestone Jun 4, 2024
@samhouts samhouts removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 3, 2024
@samhouts samhouts added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 10, 2024
@lukassoo
Copy link

For anyone experiencing this issue - a workaround is to use the community toolkit "TouchBehaviour":
https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/behaviors/touch-behavior?tabs=toucheffect-xaml%2Ctouchbehavior-xaml

@christoroth
Copy link

For anyone experiencing this issue - a workaround is to use the community toolkit "TouchBehaviour": https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/behaviors/touch-behavior?tabs=toucheffect-xaml%2Ctouchbehavior-xaml

From what I can see (and I really hope I'm wrong!) TouchBehavior cannot tell you where the touch events happened which is a key difference for me from TapGestureRecognizer (which cannot tell you when it started) or PointerGestureRecognizer which works great on windows (location and start/stop/move) but seems to do nothing in Android.

@lukassoo
Copy link

lukassoo commented Sep 7, 2024

@christoroth For my use case the position didn't matter.
I had a look and only see that there are two properties relating to the position:
image

But the way it reads it may be pointing to the position of the element being pressed.
I hope the MAUI team eventually gets through the mountain of issues and fixes this as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-gestures Gesture types platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.