23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

FIGURE 9-1 The PointerEvents example display (screen shot cropped a bit to show detail).<br />

Within the handlers for all of the MSPointer* events, the eventArgs object contains a whole roster of<br />

properties. One of them, pointerType, identifies the type of input: touch (2), pen (3), and mouse (4). This<br />

property lets you implement different behaviors for different input methods, if desired. Each event<br />

object also contains a unique pointerId value that identifies a stroke or a path for a specific contact<br />

point, allowing you to correlate an initial MSPointerDown event with subsequent events. When we look at<br />

gestures in the next section, we’ll also see how we use the pointerId of MSPointerDown to associate a<br />

gesture with a pointer.<br />

The complete roster of properties that come with the event is actually far too much to show here, as<br />

it contains many of the usual DOM properties along with many pointer-related ones from an object<br />

type called MSPointerEvent. The best way to see what shows up is to run some code like the Input<br />

DOM pointer event handling sample (a canvas drawing app), set a breakpoint within a handler for one<br />

of the events, and examine the event object. The table on the following page describes some of the<br />

properties (and a few methods) relevant to our discussion here.<br />

376

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!