Quickly build Windows 8-style apps 35-touch input

Source: Internet
Author: User

Original: Quick build Windows 8 style Apps 35-touch input

Reference

Windows 8 devices typically have a multi-touch screen that allows users to use multiple fingers simultaneously for different input interactions, such as tapping, dragging, or shrinking gestures. In addition, the touch, mouse, and pen/stylus interactions in Windows 8 are received, processed, and managed as pointer input.

First, gesture processing

Let's start with a summary of what common gestures are in Windows 8.

1, click: Touch the screen with one finger, then lift your finger.

2, Long press: touch the screen with one finger and remain motionless.

3, Swipe: Touch the screen with one or more fingers and move in the same direction.

4, Swipe: Touch the screen with one or more fingers and move a shorter distance in the same direction.

5, Pinch: Touch the screen with two or more fingers, then close the fingers together or separate.

6, Rotate: Touch the screen with two or more fingers and move along a clockwise or counterclockwise arc.

7, Stretch: Touch the screen with two or more fingers, and then separate the fingers.

How do we handle gestures in Windows 8?

Let's take a look at the Windows 8 gesture API:

These gestures are handled based on the manipulation API, where hold and tap gestures are encapsulated based on manipulation, and other gestures are handled using the manipulation API.

Here are a few common events in the manipulation API:

    • Manipulationstarting: Triggered when the Operation processor is first created.
    • Manipulationstarted: Triggered when the input device starts operation on the UIElement object.
    • Manipulationdelta: Triggered when the input device changes position during operation.
    • Manipulationcompleted: triggered when the operation and delay of the UIElement object are complete.
    • Manipulationinertiastarting: Triggered when the input device loses contact with the UIElement object during operation and the delay begins.

Click the gesture (double click, right clicking):

Click here for an example (double-click, right-click to handle the same way):

Often we can implement actions such as jumping a page by clicking an event, and work with code business logic in "openingmessage_tapped".

Press and hold the gesture:

Usually we can press an item in the app and keep, browse more information about the item, similar to the WindowsPhone in the long press a text message, you can choose to copy, forward, delete and other operations.

Glide drag gesture:

Usually we can drag the picture through the glide drag gesture, because the API which does not provide the glide drag gesture operation, can only be achieved by handling the Manipulationdelta event.

Pinch to go:

We can scale the picture with this gesture, because the API that does not provide the zoom gesture operation can only be achieved by handling the Manipulationdelta event.

Rotation gestures:

We can rotate the picture by rotating the gesture, in fact the logic is relatively simple, only need to deal with the current picture angle + (image angle *180/pi value), and then re-assign the value of the line.

Second, the pointer processing

Previous application processing of the mouse, touch and stylus response, requires a number of different event handlers, it is easy to cause poor code quality, easy to produce copy and paste errors. By analyzing some of the similarities between different devices and forms, Microsoft finally integrates the method of pointer input into a consistent API. Using pointer events for the mouse, touch and stylus create a consistent, simple experience.

The following are common events for pointer event handling:

(Take an example of drawing on a picture)

1,pointerpressed: Occurs when a finger, mouse, or stylus taps the screen.

The current pointer is collected when the pointer is pressed.

2,pointermoved: Occurs when a finger, mouse, or stylus is dragged on the screen.

You can draw a line from the previous click position and the current click position by triggering the Pointermoved event.

3,pointerreleased: Occurs when a finger, mouse, or stylus is lifted.

You can remove the click location from the collection by triggering the Pointerreleased event.

4,pointerexited: Occurs when a finger, mouse, or stylus leaves.

You can remove the click location from the collection by triggering the Pointerexited event.

The interactive advantage of the pointer and gesture system

1, helps to improve application performance

2, simplified handling of large amounts of input to send automatic touches

3, reduce the amount of code written

4, help alleviate the development dilemma

for more information on gesture and pointer processing, refer to :

1, modern input in Windows 8;

2, QuickStart: Pointers (Windows Store apps using C#/vb/c++ and XAML) (Windows);

3, QuickStart: Touch input (Windows store apps using C#/vb/c++ and XAML) (Windows);

4,input:xaml user Input Events sample;

Quickly build Windows 8-style apps 35-touch input

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.