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

B. Clay Shannon picture B. Clay Shannon · Nov 10, 2012 · Viewed 17.7k times · Source

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"/>

?

Answer

Jeremy Likness picture Jeremy Likness · Nov 21, 2012

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."