Skip to content

Latest commit

 

History

History
63 lines (40 loc) · 5.97 KB

pointerroutedeventargs.md

File metadata and controls

63 lines (40 loc) · 5.97 KB
-api-id -api-type
T:Microsoft.UI.Xaml.Input.PointerRoutedEventArgs
winrt class

Microsoft.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.

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 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 language="csharp" source="code/PointerInput/csharp/MainWindow.xaml.cs" id="SnippetPointerMoved":::

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 Handle pointer input for the complete example.)

:::code language="csharp" source="code/PointerInput/csharp/MainWindow.xaml.cs" id="SnippetQueryPointer":::

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.

-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]

-see-also

RoutedEventArgs, PointerPressed, PointerPressed