Help with didTouchDownAtScreenPoint

446
0
09-18-2018 07:23 AM
WorthSparks
New Contributor III

I am trying to implement the <AGSGeoViewTouchDelegate> protocol to use the didTouchDownAtScreenPoint method to tell AGSMapView to ignore my own touch-and-drag gesture recognizer, which is used for drawing pencil strokes in the map. By testing, I have discerned some of the functionality, but I still have to guess at the rest. Here is what I have learned:

  • If I omit didTouchDownAtScreenPoint, all touch input that is not captured by my drag gesture recognizer (and some that is) gets recognized by the AGSMapView, even if I have previously set interactionOptions.isEnabled = false.
  • If I implement didTouchDownAtScreenPoint but never call the provided completion block, AGSMapView captures no touches, which is the behavior I want. But the problem is that the next touch, which is intended for AGSMapView interaction, is ignored.

So it appears the completion block is the key. Because it is @escaping, I can hold onto the completion block for execution later, like when my gesture recognizer's drag is complete. Calling it with completion(true) when my drag is complete works great and almost solves the problem. However, I still don't know what to do with second-finger touches that may occur during my first-finger drag gesture. Through testing, I see that second-finger touches also call didTouchDownAtScreenPoint with their own completion blocks. For now, I am guessing I should keep all the completion blocks I receive in an array until I finish my gesture, and then call each of them with completion(true) in the order I received them. This also appears to work but it sure doesn't feel right. I have no idea if I am causing other problems by doing it this way.

The only documentation I can find is in the reference. And the only example I can find is in Viewshed (location). Neither the reference nor the example show anything about touch events coming from a second finger during the drag of the first. I am wondering if there is more documentation somewhere describing how the completion block should be used in more complex cases such as mine. By the way, if I can use this way to tell AGSMapView to stop taking touch input, it might solve the problem I was describing in an older thread.

0 Kudos
0 Replies