Cannot detect taps on PlatformViews #49084
Comments
|
With the PlatformViewSurface's hitTestBehavior set to transparent, the surface is not hittested and doesn't enter the arena, leaving the tap detector to be the default winner. |
|
The TapGestureRecognizer only accepts gestures as the default winner (when there are no other recognizers the claim the gesture, Dartdoc). A PlatformViewSurface currently always contributes a member to the arena which prevents the tap detector from winning. In some sense this is working as intended, as the tap recognizer says "I only recognizer when I know nothing else wants the touches", and a platform view that has non transparent hit test behavior is always "interested" in the touch events. @hterkelsen can you describe the concrete use case for this? |
|
I'm trying to get the It works on Android and iOS because the |
|
Does the video player HtmlElementView need to block any touch events from being used by the framework? if not would it make sense to set the hit testing behavior to transparent? |
|
I guess not. Unfortunately I hard-coded I am going to write a PR that adds better gesture support for |
|
This may just be my lack of familiarity with the gesture system but this behavior is still surprising to me, especially since the test case above would pass if instead of It was my assumption that the |
|
@amirh By use case, you mean the general desirability of catching the tap over a PlatformView? If so, by all means. I have a PlatformView that implements some shader operations that Google, for some reason, decided to remove from Skia about two years ago (I tried to convince them not to do it but I failed). But, apart from that, I need to treat them just as any other image in Flutter, including the user tapping on it to start something. |
|
Any updates on this? |
|
So I've run into this problem while trying to display SVG icons on web - found a workaround for my use case (which was simply registering onTap listener):
Hope this helps some people |
|
Hi @vishna, can you include a code sample of what your workaround was? I've tried to replicate it but have been unsuccessful. |
If you have a
GestureDetectorparent of aPlatformView, then theonTapof theGestureDetectoris not called even when thePlatformViewhas no gesture detectors. I wrote a test case showing the issue:The test case fails both
expects.@amirh suggested changing the
GestureDetector'sbehaviortoHitTestBehavior.opaqueand thePlatformViewSurface'shitTestBehaviortoPlatformViewHitTestBehavior.transparent, which causes the test to pass, but I'm not 100% sure why.The text was updated successfully, but these errors were encountered: