Пример #1
0
        public override bool DispatchTouchEvent(MotionEvent e)
        {
            if (e.Action == MotionEventActions.Down)
            {
                downTime     = DateTime.UtcNow;
                downPosition = new Xamarin.Forms.Point((double)e.RawX, (double)e.RawY);
            }
            if (e.Action != MotionEventActions.Up)
            {
                return(base.DispatchTouchEvent(e));
            }
            Android.Views.View currentFocus1 = ((Activity)Context).CurrentFocus;
            bool flag = base.DispatchTouchEvent(e);

            if (currentFocus1 is EditText)
            {
                Android.Views.View currentFocus2 = ((Activity)Context).CurrentFocus;
                if (currentFocus1 == currentFocus2 && this.downPosition.Distance(new Xamarin.Forms.Point((double)e.RawX, (double)e.RawY)) <= ContextExtensions.ToPixels(Context, 20.0) && !(DateTime.UtcNow - downTime > TimeSpan.FromMilliseconds(200.0)))
                {
                    int[] location = new int[2];
                    currentFocus1.GetLocationOnScreen(location);
                    float num1 = e.RawX + currentFocus1.Left - location[0];
                    float num2 = e.RawY + currentFocus1.Top - location[1];
                    if (!new Rectangle((double)currentFocus1.Left, (double)currentFocus1.Top, (double)currentFocus1.Width, (double)currentFocus1.Height).Contains((double)num1, (double)num2))
                    {
                        ContextExtensions.HideKeyboard(Context, currentFocus1);
                        RequestFocus();
                        currentFocus1.ClearFocus();
                    }
                }
            }
            return(flag);
        }
Пример #2
0
 protected override void OnDetachedFromWindow()
 {
     Device.StartTimer(TimeSpan.FromMilliseconds(0), () =>
     {
         ContextExtensions.HideKeyboard(Context, ((Activity)Forms.Context).Window.DecorView);
         return(false);
     });
     base.OnDetachedFromWindow();
 }
Пример #3
0
 protected override void OnAttachedToWindow()
 {
     ContextExtensions.HideKeyboard(Context, ((Activity)Forms.Context).Window.DecorView);
     base.OnAttachedToWindow();
 }