0

Edit: I am editing my initial question (see below for history) as I am getting new information.

I figured out that when the swipe motion starts from inside the button bounds, we never receive TouchesEnded or TouchesCancelled, only TouchesMoved. However, if I can react on WillEnddragging, it would be great. Is it possible to cancel a gesture on WillEndDragging and also pass this cancel down the children chain?


History:

I am using Xamarin Forms and I have the following issue I have custom controls part of native scrolling views, like ScrollView or CollectionView, that remain in "clicked" state after the finger enters them but then initiates a scroll gesture.

I had a similar issue on UWP in the past and managed to solve it with the UIElement.PointerCaptureLost event.

Sorry if I am wasting your time on trivial stuff, but I am really stuck and I greatly appreciate your help.

I have tried different approaches suggested, including setting DelaysContentTouches to NO, and playing around with CanCancelContentTouches and overriding TouchesShouldCancelInContentView to always return NO, in a ScrollView custom renderer.

I have had a read of Allow UIScrollView and its subviews to both respond to a touch and UIScrollView sending touches to subviews

Maybe the accepted answer here helps, but I am not sure how to get the tag of my custom view.

What I am expecting is my custom controls to receive the cancelled touch event (or something similar) as happens in both Android and Windows

TheDeC
  • 11
  • 3
  • I think you need to provide the code for one of your "custom controls" ... it's very possible you are missing some event handling. – DonMag Nov 07 '22 at 14:13
  • @DonMag The controls work as expected on the other platforms (Android and UWP currently). In Android, I see in the DispatchTouchEvent() method, the `MotionEvent.ActionMasked` is of type `MotionEventActions.Cancelled`. It could be very much the case that my iOS UIGestureRecognizer is missing something, but as I understand the only montion capturing methods I have are `TouchesBegan`, `Moved`, `Exited` and `Cancelled`. Unfortunately `TouchesCancelled` does not fire at this case, and I was wondering how other devs do it. I'm sorry I cannot include much code, this is a work project – TheDeC Nov 07 '22 at 14:26
  • It would, of course, be easier if you could put together a minimal example of what you're doing for a custom control... Have you also implemented `touchesEnded`? – DonMag Nov 07 '22 at 15:15
  • Did you add Gesture Recognizers to your view? They could interfere with TouchesCancelled. – Zack Nov 08 '22 at 03:13
  • @DonMag yes I have. However, I see from debugging that when the issue occurs, the last Touches method that fires is `TouchesMoved`. So, to fix the issue, I send a "Released" event, when a button receives `TouchesMoved`. However, this is not optimal, as then the button might be unresponsive. Looks to me like the touch events get "lost" somehow? – TheDeC Nov 09 '22 at 11:09

1 Answers1

0

This was easier than it looked. Solved by adding a UIGestureRecognizerDelegate to my UIGestureRecognizer class and in the delegate I overwrote ShouldRecognizeSimultaneously to return true.

TheDeC
  • 11
  • 3