Skip to content

Latest commit

 

History

History
76 lines (47 loc) · 6.66 KB

pointerroutedeventargs.md

File metadata and controls

76 lines (47 loc) · 6.66 KB
-api-id -api-type
T:Windows.UI.Xaml.Input.PointerRoutedEventArgs
winrt class

Windows.UI.Xaml.Input.PointerRoutedEventArgs

-description

Contains the arguments returned by the last pointer event message.

-remarks

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:

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]

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.

Version history

Windows version SDK version Value added
1709 16299 IsGenerated

-examples

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]

-see-also

RoutedEventArgs, PointerPressed, PointerPressed