summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2017-06-21 11:13:06 (GMT)
committerRui Marinho <me@ruimarinho.net>2017-06-21 11:13:06 (GMT)
commitc6f547b298f95a35e5fa16eca6fd7b8b6a0a0920 (patch)
tree9d35af55c208010814a4f5a137efd93453e15bdc /Xamarin.Forms.Platform.iOS
parentc09603732916be56d27f21cea4ef1370057414bc (diff)
downloadxamarin-forms-c6f547b298f95a35e5fa16eca6fd7b8b6a0a0920.zip
xamarin-forms-c6f547b298f95a35e5fa16eca6fd7b8b6a0a0920.tar.gz
xamarin-forms-c6f547b298f95a35e5fa16eca6fd7b8b6a0a0920.tar.bz2
Allow multiple tap gestures to fire simultaneously on iOS (#964)
* Allow multiple tap gestures to fire simultaneously on iOS * Verify that the tap came from the same UIView
Diffstat (limited to 'Xamarin.Forms.Platform.iOS')
-rw-r--r--Xamarin.Forms.Platform.iOS/EventTracker.cs46
1 files changed, 43 insertions, 3 deletions
diff --git a/Xamarin.Forms.Platform.iOS/EventTracker.cs b/Xamarin.Forms.Platform.iOS/EventTracker.cs
index 5b2156c..7be924a 100644
--- a/Xamarin.Forms.Platform.iOS/EventTracker.cs
+++ b/Xamarin.Forms.Platform.iOS/EventTracker.cs
@@ -254,11 +254,51 @@ namespace Xamarin.Forms.Platform.MacOS
UITapGestureRecognizer CreateTapRecognizer(int numTaps, Action action, int numFingers = 1)
{
- var result = new UITapGestureRecognizer(action);
- result.NumberOfTouchesRequired = (uint)numFingers;
- result.NumberOfTapsRequired = (uint)numTaps;
+ var result = new UITapGestureRecognizer(action)
+ {
+ NumberOfTouchesRequired = (uint)numFingers,
+ NumberOfTapsRequired = (uint)numTaps,
+ ShouldRecognizeSimultaneously = ShouldRecognizeTapsTogether
+ };
+
return result;
}
+
+ static bool ShouldRecognizeTapsTogether(NativeGestureRecognizer gesture, NativeGestureRecognizer other)
+ {
+ // If multiple tap gestures are potentially firing (because multiple tap gesture recognizers have been
+ // added to the XF Element), we want to allow them to fire simultaneously if they have the same number
+ // of taps and touches
+
+ var tap = gesture as UITapGestureRecognizer;
+ if (tap == null)
+ {
+ return false;
+ }
+
+ var otherTap = other as UITapGestureRecognizer;
+ if (otherTap == null)
+ {
+ return false;
+ }
+
+ if (!Equals(tap.View, otherTap.View))
+ {
+ return false;
+ }
+
+ if (tap.NumberOfTapsRequired != otherTap.NumberOfTapsRequired)
+ {
+ return false;
+ }
+
+ if (tap.NumberOfTouchesRequired != otherTap.NumberOfTouchesRequired)
+ {
+ return false;
+ }
+
+ return true;
+ }
#else
NSPanGestureRecognizer CreatePanRecognizer(int numTouches, Action<NSPanGestureRecognizer> action)
{