public override bool OnTouchEvent(TextView textView, ISpannable spannable, MotionEvent e)
        {
            try
            {
                var action = e.Action;
                switch (action)
                {
                case MotionEventActions.Down:
                {
                    PressedSpan = GetPressedSpan(textView, spannable, e);
                    if (PressedSpan != null)
                    {
                        PressedSpan.SetPressed(true);
                        Selection.SetSelection(spannable, spannable.GetSpanStart(PressedSpan), spannable.GetSpanEnd(PressedSpan));
                    }

                    break;
                }

                case MotionEventActions.Move:
                {
                    XTouchableSpan touchedSpan = GetPressedSpan(textView, spannable, e);
                    if (PressedSpan != null && touchedSpan != PressedSpan)
                    {
                        PressedSpan.SetPressed(false);
                        PressedSpan = null !;
                        Selection.RemoveSelection(spannable);
                    }

                    break;
                }

                default:
                {
                    if (PressedSpan != null)
                    {
                        PressedSpan.SetPressed(false);
                        base.OnTouchEvent(textView, spannable, e);
                    }

                    PressedSpan = null !;
                    Selection.RemoveSelection(spannable);
                    break;
                }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }

            return(true);
        }
Exemple #2
0
        public override bool OnTouchEvent(TextView textView, ISpannable spannable, MotionEvent e)
        {
            var action = e.Action;

            if (action == MotionEventActions.Down)
            {
                PressedSpan = GetPressedSpan(textView, spannable, e);
                if (PressedSpan != null)
                {
                    PressedSpan.SetPressed(true);
                    Selection.SetSelection(spannable, spannable.GetSpanStart(PressedSpan), spannable.GetSpanEnd(PressedSpan));
                }
            }
            else if (action == MotionEventActions.Move)
            {
                XTouchableSpan touchedSpan = GetPressedSpan(textView, spannable, e);
                if (PressedSpan != null && touchedSpan != PressedSpan)
                {
                    PressedSpan.SetPressed(false);
                    PressedSpan = null;
                    Selection.RemoveSelection(spannable);
                }
            }
            else
            {
                if (PressedSpan != null)
                {
                    PressedSpan.SetPressed(false);
                    base.OnTouchEvent(textView, spannable, e);
                }

                PressedSpan = null;
                Selection.RemoveSelection(spannable);
            }

            return(true);
        }