Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Does Xamarin.Forms trap touches in the application?

$
0
0

Evening,

I'm trying to implement a global activity timeout feature to auto log users out of my application after a predetermined amount of time. I've gone through a couple of different implementations but seem to get stuck on something each time. My current attempt, following a guide here, is as follows:

AppDelegate.cs

    var tapRecognizer = new InteractionGestureRecognizer { CancelsTouchesInView = false };
    this.window.AddGestureRecognizer(tapRecognizer);

InteractionGestureRecognizer.cs:

        class InteractionGestureRecognizer : UITapGestureRecognizer
        {
            public override void TouchesBegan(NSSet touches, UIEvent evt)
            {
                Debug.WriteLine("TouchesBegan: " + touches);
                base.TouchesBegan(touches, evt);
            }

            public override void TouchesMoved(NSSet touches, UIEvent evt)
            {
                Debug.WriteLine("TouchesMoved: " + touches);

                base.TouchesMoved(touches, evt);
            }

            public override void TouchesEnded(NSSet touches, UIEvent evt)
            {
                Debug.WriteLine("TouchesEnded: " + touches);

                base.TouchesEnded(touches, evt);
            }

            public override void TouchesCancelled(NSSet touches, UIEvent evt)
            {
                Debug.WriteLine("TouchesCancelled: " + touches);

                base.TouchesCancelled(touches, evt);
            }
        }

I'm getting absolutely no debug lines, and touches to my app don't reach any subviews so tapping a field doesn't pop up a keyboard etc.

Other things I've tried are:

  1. In shared code, looping through the children of the StackLayout and attaching a Focused, Clicked or Tapped event to each element, but this didn't capture touches on the background or scrolls on a table view

  2. A standard, non sub classed, UITapGestureRecognizer with NumberOfTaps set to 1 applied directly to the UIWindow but this seemed to stop any taps on a ListView

  3. Probably something else but I've forgotten now!

Can anyone notice an obvious mistake or guide me to a way to implement a feature like this?

Thanks in advance


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>