void OnLongPressed(UILongPressGestureRecognizer gr)
        {
            if (_panning)
            {
                return;
            }
            if (!_element.IsVisible)
            {
                return;
            }

            if (gr.State == UIGestureRecognizerState.Ended || gr.State == UIGestureRecognizerState.Cancelled || gr.State == UIGestureRecognizerState.Failed)
            {
                _longPressing = false;
                if (_startPressing != null)
                {
                    _startPressing.Stop();
                    foreach (var listener in _listeners)
                    {
                        //if (handled)
                        //	break;
                        if (listener.HandlesLongPressed)
                        {
                            LongPressEventArgs args = new iOSLongPressEventArgs(gr, _startPressing.ElapsedMilliseconds)
                            {
                                Listener = listener
                            };
                            listener.OnLongPressed(args);
                            if (args.Handled)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            else if (!_longPressing)
            {
                _longPressing = true;
                if (_startPressing == null)
                {
                    _startPressing = new Stopwatch();
                }
                else
                {
                    _startPressing.Reset();
                }
                _startPressing.Start();
                foreach (var listener in _listeners)
                {
                    if (listener.HandlesLongPressing)
                    {
                        LongPressEventArgs args = new iOSLongPressEventArgs(gr, 0L)
                        {
                            Listener = listener
                        };
                        listener.OnLongPressing(args);
                        if (args.Handled)
                        {
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 void OnLongPressed(UILongPressGestureRecognizer gr)
 {
     if (_panning)
     {
         return;
     }
     if (!_element.IsVisible)
     {
         return;
     }
     if (touchCount == 0)
     {
         //System.Diagnostics.Debug.WriteLine("onLongPressed set _viewLocationAtOnDown");
         _viewLocationAtOnDown = ViewLocationInWindow(gr.View);
     }
     if (gr.State == UIGestureRecognizerState.Ended || gr.State == UIGestureRecognizerState.Cancelled || gr.State == UIGestureRecognizerState.Failed)
     {
         _longPressing = false;
         if (_startPressing != null)
         {
             _startPressing.Stop();
             bool handled = false;
             foreach (var listener in _listeners)
             {
                 //if (handled)
                 //	break;
                 if (listener.HandlesLongPressed)
                 {
                     LongPressEventArgs args = new iOSLongPressEventArgs(gr, _startPressing.ElapsedMilliseconds, _viewLocationAtOnDown);
                     args.Listener = listener;
                     listener.OnLongPressed(args);
                     handled = handled || args.Handled;
                     if (handled)
                     {
                         break;
                     }
                 }
             }
             //gr.CancelsTouchesInView = handled;
             //if (handled)
             //	return;
         }
     }
     else if (!_longPressing)
     {
         _longPressing = true;
         if (_startPressing == null)
         {
             _startPressing = new Stopwatch();
         }
         else
         {
             _startPressing.Reset();
         }
         _startPressing.Start();
         bool handled = false;
         foreach (var listener in _listeners)
         {
             //if (handled)
             //	break;
             if (listener.HandlesLongPressing)
             {
                 LongPressEventArgs args = new iOSLongPressEventArgs(gr, 0L, _viewLocationAtOnDown);
                 args.Listener = listener;
                 listener.OnLongPressing(args);
                 handled = handled || args.Handled;
                 if (handled)
                 {
                     break;
                 }
             }
         }
         //gr.CancelsTouchesInView = handled;
     }
 }