Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Click, Tapped, and PointerPressed synonymous in WinRT-XAML?

Does it matter whether I create event handlers for PointerPressed, Click, or Tapped?IOW, is there any functional difference between the following:

<Button x:Name="BackButton" PointerPressed="BackButton_Click"/>     <Button x:Name="BackButton" Click="BackButton_Click"/>     <Button x:Name="BackButton" Tapped="BackButton_Click"/> 

?

like image 263
B. Clay Shannon-B. Crow Raven Avatar asked Nov 10 '12 02:11

B. Clay Shannon-B. Crow Raven


1 Answers

Click is there for backwards compatibility, and is essentially the same as Tapped. Tapped is a "high level gesture" that will translate automatically to a click, tap, pen press, etc. and is what I would recommend to use.

PointerPressed is not what you want. Here's why: if I press and hold, the PointerPressed event will fire when I initially "press" and then a PointerReleased will fire once it's done. This is more low-level and you can make decisions about how long it was pressed, etc. Typically a long press is NOT what you want to consider a "Click" or a "Tap" because by definition Tap is shorter duration. Therefore, for what you want, "Tap" conveys it best because it translates the gesture for you using the system timing for what is considered a "Tap" vs. a hold and automatically promotes clicks and pen presses to the same event. PointerPressed will fire whenever a button is pressed or a finger is pressed regardless of how long the interaction lasts.

I have a fairly involved app that demonstrates the various interactions that you can download from http://windows8applications.codeplex.com - just refer to the Chapter 4 sample called "Touch."

like image 149
Jeremy Likness Avatar answered Oct 12 '22 23:10

Jeremy Likness