0

I have an app with a game board and can pick up and move tiles around with panning using mr.gestures, that's working well.

My game board is a MR.Gestures.AbsoluteLayout and that's where I capture the panning gesture.

If I add that game board as a child to another MR.Gestures.AbsoluteLayout then it seems the gestures are blocked by the parent and it no longer works.

Is there a way to pass gestures though to children or ignore gestures on a parent in some way?

Cheesebaron
  • 24,131
  • 15
  • 66
  • 118
Daniel
  • 1,317
  • 2
  • 11
  • 21
  • Is this on all platforms or just one? – Cheesebaron May 03 '16 at 21:28
  • can you use a regular AbsoluteLayout for the outer container? – Jason May 03 '16 at 21:51
  • Did you ever solve your issue? I too am experiencing something similar with a MR.Gestures.StackLayout with MR.Gestures.Label objects as children, I need to use both of their "Tapped" events. My issue appears only to be with iOS and tapping the Labels works fine on Android. – xceed Aug 12 '16 at 12:12

1 Answers1

0

Is there a way to pass gestures though to children or ignore gestures on a parent in some way?

For me this problem appeared only on Android.. The answer is Yes:

When parent receives gesture event it must check if finger x,y is within specific childs views. If yes, parent just ignores the gesture.

Regarding the code, ill just past one event handler to get the idea. In my case i have 2 childs (like and bookmark) over a parent frame:

enter image description here

    //-------------------------------------------------------------------
    private void OnTapped_MainFrame(object sender, TapEventArgs e)
    //-------------------------------------------------------------------
    {
        //Get parent screen abs pos in pixels
        //We are using native code get absolute screen position
        var ptFrame = DependencyService.Get<INiftyHelpers>().GetViewAbsolutePosition((View)sender);

        //Gets childs (hotspots) screen abs position in pixels
        var ptFav = DependencyService.Get<INiftyHelpers>().GetViewAbsolutePosition((View)hsFav);
        var ptLike = DependencyService.Get<INiftyHelpers>().GetViewAbsolutePosition((View)hsLike);

        //Gets childs (hotspots) rectangles, everything in pixels using screen density
        var rectFav = new Rectangle(ptFav, new Size(hsFav.Width * AppHelper.DisplayDensity, hsFav.Height * AppHelper.DisplayDensity));
        var rectLike = new Rectangle(ptLike, new Size(hsLike.Width * AppHelper.DisplayDensity, hsLike.Height * AppHelper.DisplayDensity));

        //Convert the finger XY to screen pos in pixels
        var ptTouch = new Point(ptFrame.X + e.Center.X * AppHelper.DisplayDensity, ptFrame.Y + e.Center.Y * AppHelper.DisplayDensity); //absolute relative to screen

        //check if withing childs
        if (rectFav.Contains(ptTouch) || rectLike.Contains(ptTouch))
            return; //Ignore input and let childs process their gestures!

        //Process input
        //..

    }
Nick Kovalsky
  • 5,378
  • 2
  • 23
  • 50