Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling 2, 3, 4, 5 Fingers Tapped, DoubleTap & Holding Gestures in WinRT App

I can easily handle 1 finger Tapped, DoubleTap and Holding gestures like this:

public MainPage()
{
    this.InitializeComponent();
    this.Tapped += mc_Tapped;
    this.DoubleTapped += mc_DoubleTapped;
    this.Holding += mc_Holding;
}
public void mc_Tapped(object sender, TappedRoutedEventArgs e)
{
    //Tap
}
public void mc_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{
    //DoubleTap
}
public void mc_Holding(object sender, HoldingRoutedEventArgs e)
{
    //Hold
}

But the events don't have a property to get the number of fingers and they don't even get fired when more than 1 touch contact is present on the screen. I also want to handle 2, 3, 4, 5 fingers Tapped, DoubleTap and Holding gestures. Can anyone tell me how to do that?

like image 559
Elmo Avatar asked Oct 22 '12 12:10

Elmo


1 Answers

You'll have to work with the PointerRoutedEventArgs that are passed on Pointer events (ie. Pressed, entered, released and such) and do it the hard way

Each time pointer enters the control is assigned a unique pointer ID.I would create a Dictionary and add each pointer to that dictionary as it is pressed on the control (and obviously remove them when they exit). Then in your existing tapped, double tapped and such handlers just check how many pointers are in your dictionary and call the appropriate handlers

like image 134
sLedgem Avatar answered Nov 02 '22 17:11

sLedgem