maui icon indicating copy to clipboard operation
maui copied to clipboard

SwipeGestureRecognizer is not working

Open Symbai opened this issue 3 years ago • 20 comments
trafficstars

Description

SwipeGestureRecognizer is not working on Android, the Swiped event is never raised. I only found this issue #14 which says its in Pending state but the issue hasn't been updated since 2 years. The documentation for MAUI sounds like it's implemented.

Is this a bug or is it really not implemented yet?

Steps to Reproduce

<Button>
          <Button.GestureRecognizers>
                    <SwipeGestureRecognizer Direction="Right" Swiped="SwipeGestureRecognizer_Swiped"/>
          </Button.GestureRecognizers>
</Button>

SwipeGestureRecognizer_Swiped event is never raised when I swipe in Android Simulator.

Version with bug

Release Candidate 3 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12, API 31, Android Simulator

Did you find any workaround?

No response

Relevant log output

No response

Symbai avatar May 22 '22 13:05 Symbai

Does it work if you use it on another element? Preferably one that does not have its own response to input? A Label maybe?

jfversluis avatar May 23 '22 07:05 jfversluis

Thanks for asking. It also does NOT work on a Label:

https://user-images.githubusercontent.com/14368203/169767229-cff1d53a-3515-4afd-aba7-bf925786010f.mp4

Symbai avatar May 23 '22 07:05 Symbai

not repro with vs main build(32523.339.main).

VincentBu avatar May 24 '22 06:05 VincentBu

Can you repro this with RC3? I am not able to test main build but with RC3 so question is if its just RC3 vs main or if its just you aren't able to reproduce at all.

Symbai avatar May 24 '22 08:05 Symbai

Here is my project, would you like to verify it on Android emulator? Just swipe the button and the counter is expected to increase. MauiApp7403.zip

VincentBu avatar May 24 '22 08:05 VincentBu

RC3, API 31, Android 12, Pixel 5 => NOT working. Assuming you tested it on Android 12 API 31 as well, then you or someone else need to test it on RC3 to make sure this is definitely fixed. But I doubt this is "suddenly" fixed in main branch because I cannot find any issue about that. So even if main branch goes live it probably wouldn't work on my end as well.

https://user-images.githubusercontent.com/14368203/169996780-5b8d2980-9589-487c-8a15-3e813e314b69.mp4

.

Symbai avatar May 24 '22 09:05 Symbai

It is definitely implemented (GestureManager class). Testing on the current amin branch seems to work fine. fix-7403

Could you try with GA?

jsuarezruiz avatar May 24 '22 14:05 jsuarezruiz

Hi @Symbai. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar May 24 '22 14:05 ghost

I dont know how to try the main branch. Is there an installer? I'm not good at cloning and building and running such large projects. Like I said I'm using RC3 via VS installer. I believe its easier for you to run it on that, then having me trying to get the main branch working.

If it doesn't work for you on RC3 as well but it works in main, then we can close the issue. But if it also works for you in RC3, then its just broken on my end and we need to figure out why.

Symbai avatar May 24 '22 16:05 Symbai

@jsuarezruiz I've now downloaded the MAIN branch following this guide. And it still does not work. No idea why it does for you, are you using the same Android version and device?

Symbai avatar Jun 03 '22 06:06 Symbai

I confirm it works on GA with Label, but doesn't work on custom controls

VladislavAntonyuk avatar Jun 23 '22 07:06 VladislavAntonyuk

What are "custom controls"? I've tested this on a Button and a Listview and on both it fails.

Symbai avatar Jun 23 '22 07:06 Symbai

@VincentBu can you test gain please?

PureWeen avatar Jun 28 '22 19:06 PureWeen

@PureWeen verified with vs main build 32630.352, SwipeGestureRecognizer works fine.

VincentBu avatar Jul 01 '22 06:07 VincentBu

No idea what I am doing wrong then. Does not work in Android Emulator and on physical devices. I had 12 people testing it on their physical devices and all confirmed SwipeGesture isn't working. Can this depend on what machine you are building / publishing the project?

Symbai avatar Jul 01 '22 06:07 Symbai

Verified on 6.0.400 and it doesn't work. To check use this sample: https://github.com/VladislavAntonyuk/MauiSamples/blob/main/CardLayout/CardsLayout.cs#L86 Replace PanGestureRecognizer with SwipeGestureRecognizer. PanGestureRecognizer fires events but SwipeGestureRecognizer doesn't.

VladislavAntonyuk avatar Jul 01 '22 07:07 VladislavAntonyuk

I can confirm what @VladislavAntonyuk said. PanGestureRecognizer is also working for me (as soon as I click, hold and drag the mouse in the emulator, the event is raised), but SwipeGestureRecognizer does not. I click, hold and drag, nothing happens and the Swiped event is never raised.

These were the changes I made:

	public CardsLayout()
	{
		var panGesture = new SwipeGestureRecognizer();
		panGesture.Swiped += PanGesture_Swiped;
		GestureRecognizers.Add(panGesture);
	}

	private void PanGesture_Swiped(object? sender, SwipedEventArgs e)
	{
		throw new NotImplementedException(); // <-- never raised
	}

Symbai avatar Jul 01 '22 08:07 Symbai

repro with VladislavAntonyuk's sample.

VincentBu avatar Jul 11 '22 08:07 VincentBu

I confirm this issue still exists in .NET MAUI 7. I added swipe gesture to a content view. In Android, the gesture never works!!

codeanees avatar Nov 23 '22 19:11 codeanees

In the grid the error its the same , i think in all controls

mibuswolf avatar Nov 25 '22 20:11 mibuswolf

Today I tested Gesture Detector Handlers on Android, and custom control extending ContentView. Everything worked (Pan, Pinch, Tap) except Swipe. Maui 7.0. This is important feature, not only for custom controls.

H-A-Hristov avatar Nov 30 '22 10:11 H-A-Hristov

I am working on a sample app that I Should have out later today. It will demonstrate how to use swipe in a maui app with mvvm, using community toolkit. I am writing it now. I have it working in an app. I just want to write it all out so people can see it working with all the various layouts, buttons, images, etc. I will have examples in sample app for everyone to look at. It works out the methods microsoft put up on help pages included features not implemented yet. Using mvvm and toolkit I have figured out how to make it work.

Edit: Ok I have working solution using Maui with most layouts tested. It works in windows, android emulator, and android hardware devices. I can't test on Mac or iOS as I don't have a developer account yet. I also do not have a mac. So no direct hardware testing on Mac. After I get a Apple developer Account I can test on my Ipad.

Here is link to repo you can look it with samples that I made earlier today. https://github.com/ne0rrmatrix/SwipeGesturesSample.git

ne0rrmatrix avatar Jan 18 '23 22:01 ne0rrmatrix

https://github.com/ne0rrmatrix/SwipeGesturesSample.git

The repro link seems not to be working, could you update it?

jsuarezruiz avatar Feb 15 '23 11:02 jsuarezruiz

@jsuarezruiz please try my sample: https://github.com/VladislavAntonyuk/MauiSamples/blob/main/CardLayout/CardsLayout.cs#L86 Replace PanGestureRecognizer with SwipeGestureRecognizer. PanGestureRecognizer fires events but SwipeGestureRecognizer doesn't. https://github.com/dotnet/maui/issues/7403#issuecomment-1172064417

VladislavAntonyuk avatar Feb 15 '23 11:02 VladislavAntonyuk

https://github.com/ne0rrmatrix/SwipeGesturesSample.git

The repro link seems not to be working, could you update it?

Fixed link. https://github.com/ne0rrmatrix/MediaPlayerBugSwipeGestures for bug.

This is sample of it working without media elements. https://github.com/ne0rrmatrix/SwipeGesturesSample

Unfortunately I don't think in my case it is a bug. I have found out that exoplayer blocks swipe gestures by choice and it will not be changed. It was mentioned in closed bug report as working as intended. So you can ignore my comment as exoplayer in communitytoolkit is behaving as intended. It just overrides maui handler and blocks it.

ne0rrmatrix avatar Feb 15 '23 11:02 ne0rrmatrix

Verified this on Visual Studio Enterprise 17.6.0 Preview 6.0. This issue does not repro on Android emulator (13.0-API 33) with below Project. MauiApp7.zip

AnnYang01 avatar May 09 '23 02:05 AnnYang01

Hi @Symbai. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar May 09 '23 02:05 ghost

@jfversluis @jsuarezruiz @AnnYang01 please reopen it. the issue still reproduces (version 7.0.86) https://github.com/VladislavAntonyuk/MauiSamples/blob/main/CardLayout

Also reproduced on maccatalyst

VladislavAntonyuk avatar May 16 '23 16:05 VladislavAntonyuk