Does it matter whether I create event handlers for PointerPressed, Click, or Tapped?IOW, is there any functional difference between the following:
Jeremy's answer isn't entirely accurate. In another thread someone reported having a problem with taps not working the same way as clicks when clicking/tapping in rapid succession and it is easy to reproduce with the code below and could easily be extended to pointer events.
public sealed partial class MainPage : Page
{
private int clicks = 0;
private int taps = 0;
public MainPage()
{
this.InitializeComponent();
var button = new Button();
button.Width = 500;
button.Height = 200;
button.Content = string.Format("Clicks: {0}, Taps: {1}", clicks, taps);
button.Click += (s, e) => button.Content = string.Format("Clicks: {0}, Taps: {1}", ++clicks, taps);
button.Tapped += (s, e) => button.Content = string.Format("Clicks: {0}, Taps: {1}", clicks, ++taps);
this.Content = button;
}
}
Click is what you should handle on a regular button. It has the logic that is expected of a button. Among the things I can think of are
As demonstrated in the sample code - the Tapped event doesn't register for all taps if you tap repeatedly. I'm not sure if this is because some underlying gesture recognition logic sees some double taps or simply rejects every other tap for whatever other reason. It works for quick single touch/pen taps or mouse clicks, but is a generic event that you can handle on any UIElement and might be used if you want to distinguish between taps, double taps, right taps (!) or holds on arbitrary UI elements.
The pointer events are lower level and you can use them to handle slightly more advanced interactions not already built into the framework. As I mentioned - a click consists of a press and accompanying release both occurring on the button, so a similar interaction could be modeled with pointer events. You could, for example, use it to implement some sort of a Whac-A-Mole/Twister combination type of game where you'd want to mash many UI elements at the same time which you couldn't do with clicks.