void CheckForBoundaryHop(UITouch touch) { long id = touch.Handle.ToInt64(); TouchRecognizer recognizerHit = null; foreach (UIView view in ViewDictionary.Keys) { CGPoint location = touch.LocationInView(view); if (new CGRect(new CGPoint(), view.Frame.Size).Contains(location)) { recognizerHit = ViewDictionary[view]; } } if (!Equals(recognizerHit, IdToTouchDictionary[id])) { if (IdToTouchDictionary[id] != null) { FireEvent(IdToTouchDictionary[id], id, TouchActionType.Exited, touch, true); } if (recognizerHit != null) { FireEvent(recognizerHit, id, TouchActionType.Entered, touch, true); } IdToTouchDictionary[id] = recognizerHit; } }
void FireEvent(TouchRecognizer recognizer, long id, TouchActionType actionType, UITouch touch, bool isInContact) { // Convert touch location to Xamarin.Forms Point value CGPoint cgPoint = touch.LocationInView(recognizer.View); Point xfPoint = new Point(cgPoint.X, cgPoint.Y); // Get the method to call for firing events Action <Element, TouchActionEventArgs> onTouchAction = recognizer._touchEffect.OnTouchAction; // Call that method onTouchAction(recognizer._element, new TouchActionEventArgs(id, actionType, xfPoint, isInContact)); }
protected override void OnAttached() { // Get the iOS UIView corresponding to the Element that the effect is attached to _view = Control ?? Container; // Get access to the TouchEffect class in the PCL Impromptu.Effects.TouchHandling.TouchEffect effect = (Impromptu.Effects.TouchHandling.TouchEffect)Element.Effects.FirstOrDefault(e => e is Impromptu.Effects.TouchHandling.TouchEffect); if (effect != null && _view != null) { // Create a TouchRecognizer for this UIView _touchRecognizer = new TouchRecognizer(Element, _view, effect); _view.AddGestureRecognizer(_touchRecognizer); } }