Provides gesture and manipulation recognition, event listeners, and settings.
Syntax
public sealed class GestureRecognizer : Object
Attributes
- ActivatableAttribute(NTDDI_WIN8)
- MarshalingBehaviorAttribute(None)
- VersionAttribute(NTDDI_WIN8)
Members
The GestureRecognizer class has these types of members:
Constructors
The GestureRecognizer class has these constructors.
| Constructor | Description |
|---|---|
| GestureRecognizer | Initializes a new instance of a GestureRecognizer object. |
Events
The GestureRecognizer class has these events.
| Event | Description |
|---|---|
| CrossSliding | Occurs when a user performs a slide or swipe gesture (through a single touch contact) within a content area that supports panning along a single axis only. The gesture must occur in a direction that is perpendicular to this panning axis. |
| Dragging | Occurs when a user performs a slide or swipe gesture with a mouse or pen/stylus (single contact). |
| Holding | Occurs when a user performs a press and hold gesture (with a single touch, mouse, or pen/stylus contact). |
| ManipulationCompleted | Occurs when the input points are lifted and all subsequent motion (translation, expansion, or rotation) through inertia has ended. |
| ManipulationInertiaStarting | Occurs when all contact points are lifted during a manipulation and the velocity of the manipulation is significant enough to initiate inertia behavior (translation, expansion, or rotation continue after the input pointers are lifted). |
| ManipulationStarted | Occurs when one or more input points have been initiated and subsequent motion (translation, expansion, or rotation) has begun. |
| ManipulationUpdated | Occurs after one or more input points have been initiated and subsequent motion (translation, expansion, or rotation) is under way. |
| RightTapped | Occurs when the pointer input is interpreted as a right-tap gesture. |
| Tapped | Occurs when the pointer input is interpreted as a tap gesture. |
Methods
The GestureRecognizer class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
| Method | Description |
|---|---|
| CanBeDoubleTap | Identifies whether a tap can still be interpreted as the second tap of a double tap gesture. |
| CompleteGesture | Causes the gesture recognizer to finalize an interaction. |
| ProcessDownEvent | Processes pointer input and raises the GestureRecognizer events appropriate to a pointer down action for the gestures and manipulations specified by the GestureSettings property. |
| ProcessInertia | Performs inertia calculations and raises the various inertia events. |
| ProcessMouseWheelEvent | Processes pointer input and raises the GestureRecognizer events appropriate to a mouse wheel action for the gestures and manipulations specified by the GestureSettings property. |
| ProcessMoveEvents | Processes pointer input and raises the GestureRecognizer events appropriate to a pointer move action for the gestures and manipulations specified by the GestureSettings property. |
| ProcessUpEvent | Processes pointer input and raises the GestureRecognizer events appropriate to a pointer up action for the gestures and manipulations specified by the GestureSettings property. |
Properties
The GestureRecognizer class has these properties.
| Property | Access type | Description |
|---|---|---|
| Read/write | Gets or sets a value that indicates whether manipulations during inertia are generated automatically. | |
| Read/write | Gets or sets a value that indicates whether the exact distance from initial contact to end of the cross-slide interaction is reported.By default, a small distance threshold is subtracted from the first position reported by the system for a cross-slide interaction. If this flag is set, the distance threshold is not subtracted from the initial position. | |
| Read/write | Gets or sets a value that indicates whether the cross-slide axis is horizontal. | |
| Read/write | Gets or sets values that indicate the distance thresholds for a CrossSliding interaction. | |
| Read/write | Gets or sets a value that indicates the gesture and manipulation settings supported by an application. | |
| Read/write | Gets or sets a value that indicates the relative change in size of an object from the start of inertia to the end of inertia (when resizing, or scaling, is complete). | |
| Read/write | Gets or sets a value that indicates the rate of deceleration from the start of inertia to the end of inertia (when the resizing, or expansion, manipulation is complete). | |
| Read/write | Gets or sets a value that indicates the final angle of rotation of an object at the end of inertia (when the rotation manipulation is complete). | |
| Read/write | Gets or sets a value that indicates the rate of deceleration from the start of inertia to the end of inertia (when the rotation manipulation is complete). | |
| Read/write | Gets or sets a value that indicates the rate of deceleration from the start of inertia to the end of inertia (when the translation manipulation is complete). | |
| Read/write | Gets or sets a value that indicates the relative change in the screen location of an object from the start of inertia to the end of inertia (when the translation manipulation is complete). | |
| Read-only | Gets a value that indicates whether an interaction is being processed. | |
| Read-only | Gets a value that indicates whether a manipulation is still being processed during inertia (no input points are active). | |
| Read/write | Gets or sets a value that indicates whether the exact distance from initial contact to end of the interaction is reported.By default, a small distance threshold is subtracted from the first delta reported by the system. This distance threshold is intended to account for slight movements of the contact when processing a tap gesture. If this flag is set, the distance threshold is not subtracted from the first delta. | |
| Read-only | Gets a set of properties that are associated with the wheel button of a mouse device. | |
| Read/write | Gets or sets the center point for a rotation interaction when single pointer input is detected. | |
| Read/write | Gets or sets the radius, from the PivotCenter to the pointer input, for a rotation interaction when single pointer input is detected. | |
| Read/write | Gets or sets a value that indicates whether visual feedback is displayed during an interaction. |
Remarks
We recommend the following techniques for handling GestureRecognizer events:
- Use the target or currentTarget property of the event object instead of the GestureRecognizer object in the event handler:
The following pseudocode shows how you might set up a generic event handler for a GestureRecognizer object.
function initialize() { myGestureRecognizer = new Windows.UI.Input.GestureRecognizer(); myGestureRecognizer.addEventListener('someevent', that.someeventhandler); } function someeventhandler = function (ev) { ev.target.somemethod(); } - Set the event handler to null if it is no longer needed:
myGestureRecognizer.someeventhandler = null;
For more information on how to listen to and handle Windows Runtime events, see Using the Windows Runtime in JavaScript.
Note : This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).
Windows Phone 8
This API is not implemented and will throw an exception if called.
Examples
The following example demonstrates how to create a GestureRecognizer object and then enable manipulation and gesture events on that object through the GestureSettings property.
// Initialize gesture recognizer gr = new Windows.UI.Input.GestureRecognizer(); // Configure GestureRecognizer to detect rotation, translation, and scaling, // inertia, and tap gesture gr.gestureSettings = Windows.UI.Input.GestureSettings.manipulationRotate | Windows.UI.Input.GestureSettings.manipulationTranslateX | Windows.UI.Input.GestureSettings.manipulationTranslateY | Windows.UI.Input.GestureSettings.manipulationScale | Windows.UI.Input.GestureSettings.manipulationRotateInertia | Windows.UI.Input.GestureSettings.manipulationScaleInertia | Windows.UI.Input.GestureSettings.manipulationTranslateInertia | Windows.UI.Input.GestureSettings.tap;
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Minimum supported phone | Windows Phone 8 |
|
Namespace |
|
|
Metadata |
|
See also
- Windows.UI.Input Classes
- Using the Windows Runtime in JavaScript
- Input: manipulations and gestures using C++ sample
Build date: 2/25/2013