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.

You might notice in the table above that many of the gestures in the touch language don’t actually<br />

have a single event associated with them (like pinch or rotate) but are instead represented by a series of<br />

gesture or pointer events. The reason for this is that these gestures, when used with touch, typically<br />

involve animation of the affected content while the gesture is happening. Swipes, for example, show<br />

linear movement of the object being panned or selected. A pinch or stretch movement will often be<br />

actively zooming the content. (Semantic Zoom is an exception, but then you just let the control handle<br />

the details.) And a rotate gesture should definitely give visual feedback. In short, handling these<br />

gestures with touch, in particular, means dealing with a series of events rather than just a single one.<br />

This is one reason that it’s so helpful (and time-saving!) to use the built-in controls as much as<br />

possible, because they already handle all the gesture details for you. The ListView control, for example,<br />

contains all the pointer/gesture logic to handling pans and swipes, along with taps. The Semantic Zoom<br />

control, like I said, implements pinch and stretch by watching MSPointer* events. If you look at the<br />

source code for these controls within WinJS, you’ll start to appreciate just how much they do for you<br />

(and what it will look like to implement a rich custom control of your own, using the gesture<br />

recognizer!).<br />

You can also save yourself a lot of trouble with the -ms-touch-action <strong>CSS</strong> properties described under<br />

“<strong>CSS</strong> Styles That Affect Input.” Using this has the added benefit of processing the touch input on a<br />

non-UI thread, thereby providing much smoother manipulation than could be achieved by handling<br />

pointer or gesture events.<br />

On the theme of “write for touch and get other input for free,” all of these gestures also have mouse<br />

and keyboard equivalents, which the built-in controls also implement for you. It’s also helpful to know<br />

what those equivalents are, as shown in the table below. The “Standard Keystrokes” section later in this<br />

chapter also lists many other command-related keystrokes.<br />

Touch Keyboard Mouse Pen/Stylus<br />

Press and hold (or Right-click button Right button click Press and hold<br />

tap on text selection)<br />

Tap Enter Left button click Tap<br />

Slide (short distance) Arrow keys Left button click and drag, click on<br />

scrollbar arrows, drag the scrollbar<br />

thumb, use the mouse wheel<br />

Slide + inertia<br />

(long distance)<br />

Page Up/Page Down<br />

Left button click and drag, click on<br />

scrollbar track, drag the scrollbar<br />

thumb, use the mouse wheel<br />

Swipe to select Right-click button or spacebar Right button click Tap and drag<br />

Tap on scrollbar arrows, drag<br />

scrollbar thumb, tap and drag<br />

Tap on scrollbar track, drag<br />

scrollbar thumb, tap and drag<br />

Pinch/Stretch Ctrl+ and Ctrl- Ctrl+mouse wheel or UI command UI command or other<br />

hardware feature<br />

Swipe from edge<br />

Win+Z, Win+Tab, Win+C or<br />

Win+Shift+C<br />

Clicking on corners of the screen;<br />

right-click shows app bar<br />

Drag in from edge<br />

Rotate Ctrl+, and Ctrl+. Ctrl+Shift+mouse wheel UI command or other<br />

hardware feature<br />

368

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

Saved successfully!

Ooh no, something went wrong!