-api-id | -api-type |
---|---|
T:Windows.UI.Xaml.Input.PointerRoutedEventArgs |
winrt class |
Contains the arguments returned by the last pointer event message.
In most cases, we recommend that you get pointer info through the event argument of the pointer event handlers in your chosen language framework (Windows app using JavaScript, UWP app using C++, C#, or Visual Basic, or UWP app using DirectX with C++).
If the event argument doesn't intrinsically expose the pointer details required by your app, you can get access to extended pointer data through the GetCurrentPoint and GetIntermediatePoints methods of PointerRoutedEventArgs. Use these methods to specify the context of the pointer data.
The static PointerPoint methods, GetCurrentPoint and GetIntermediatePoints, always use the context of the app. The PointerRoutedEventArgs event data class is used for these events:
- PointerPressed
- PointerCanceled
- PointerCaptureLost
- PointerEntered
- PointerExited
- PointerMoved
- PointerReleased
- PointerWheelChanged
Important
Mouse input is associated with a single pointer assigned when mouse input is first detected. Clicking a mouse button (left, wheel, or right) creates a secondary association between the pointer and that button through the PointerPressed event. The PointerReleased event is fired only when that same mouse button is released (no other button can be associated with the pointer until this event is complete). Because of this exclusive association, other mouse button clicks are routed through the PointerMoved event. You can test the mouse button state when handling this event, as shown in the following example.
[!code-csharpPointerMoved]
[!code-csharpPointerMoved]
- The value of sender (which is on the delegate signature, not this event data class).
- Specific members of PointerRoutedEventArgs, such as KeyModifiers or GetCurrentPoint.
- Values of a Pointer device description class. Get the Pointer from the Pointer property.
- Members that come from the system input conceptualization of a PointerPoint. Use the GetCurrentPoint API to get a PointerPoint value, then call PointerPoint API such as Position and PointerPointProperties.
Specific events often have information available in the various pointer device and pointer point classes that is mainly only relevant for that event. For example, when you handle PointerWheelChanged, you might be interested in the MouseWheelDelta from PointerPointProperties.
The object retrieved by the GetCurrentPoint and GetIntermediatePoints methods provide access to extended pointer info through the Properties property, which gets a PointerPointProperties object.
In the following example, we get extended pointer properties through the PointerPoint and PointerPointProperties objects. (See Quickstart: Pointers for the complete example.)
[!code-csharpSnippetQueryPointer]
Typically, the object returned by this method is used to feed pointer data to a GestureRecognizer. Another scenario is getting the MouseWheelDelta for a PointerWheelChanged event; that value is in PointerPointProperties.
Windows version | SDK version | Value added |
---|---|---|
1709 | 16299 | IsGenerated |
The following code example shows scenario 2 from the Input sample. This code shows some usage patterns for direct manipulation using the PointerPressed, PointerReleased, PointerEntered, PointerExited, and PointerMoved events.
[!code-xamlScenario2Xaml]
[!code-csharpScenario2Code]
[!code-vbScenario2Code]