|
1 | 1 | --- |
2 | 2 | title: "Recognize a pointer gesture" |
3 | 3 | description: "Learn how to use the PointerGestureRecognizer class, to detect when the pointer enters, exits, and moves within a view on iPadOS, Mac Catalyst, and Windows." |
4 | | -ms.date: 10/24/2022 |
| 4 | +ms.date: 10/02/2023 |
5 | 5 | --- |
6 | 6 |
|
7 | 7 | # Recognize a pointer gesture |
8 | 8 |
|
9 | 9 | A .NET Multi-platform App UI (.NET MAUI) pointer gesture recognizer detects when the pointer enters, exits, and moves within a view and is implemented with the <xref:Microsoft.Maui.Controls.PointerGestureRecognizer> class. This class defines the following properties: |
10 | 10 |
|
| 11 | +::: moniker range="=net-maui-7.0" |
| 12 | + |
| 13 | +- <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerEnteredCommand>, of type `ICommand`, which is the command to invoke when the pointer enters the bounding area of the view. |
| 14 | +- <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerEnteredCommandParameter>, of type `object`, which is the parameter that's passed to <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerEnteredCommand>. |
| 15 | +- <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerExitedCommand>, of type `ICommand`, which is the command to invoke when the pointer that's in the view's bounding area leaves that bounding area. |
| 16 | +- <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerExitedCommandParameter>, of type `object`, which is the parameter that's passed to <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerExitedCommand>. |
| 17 | +- <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerMovedCommand>, of type `ICommand`, which is the command to invoke when the pointer moves while remaining within the bounding area of the view. |
| 18 | +- <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerMovedCommandParameter>, of type `object`, which is the parameter that's passed to <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerMovedCommand>. |
| 19 | + |
| 20 | +::: moniker-end |
| 21 | + |
| 22 | +::: moniker range=">=net-maui-8.0" |
| 23 | + |
11 | 24 | - <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerEnteredCommand>, of type `ICommand`, which is the command to invoke when the pointer enters the bounding area of the view. |
12 | 25 | - <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerEnteredCommandParameter>, of type `object`, which is the parameter that's passed to <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerEnteredCommand>. |
13 | 26 | - <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerExitedCommand>, of type `ICommand`, which is the command to invoke when the pointer that's in the view's bounding area leaves that bounding area. |
14 | 27 | - <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerExitedCommandParameter>, of type `object`, which is the parameter that's passed to <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerExitedCommand>. |
15 | 28 | - <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerMovedCommand>, of type `ICommand`, which is the command to invoke when the pointer moves while remaining within the bounding area of the view. |
16 | 29 | - <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerMovedCommandParameter>, of type `object`, which is the parameter that's passed to <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerMovedCommand>. |
| 30 | +- `PointerPressedCommand`, of type `ICommand`, which is the command to invoke when the pointer initiates a press within the view. |
| 31 | +- `PointerPressedCommandParameter`, of type `object`, which is the parameter that's passed to the `PointerPressedCommand`. |
| 32 | +- `PointerReleasedCommand`, of type `ICommand`, which is the command to invoke when the pointer that has previously initiated a press is released, while within the view. |
| 33 | +- `PointerReleasedCommandParameter`, of type `object`, which is the parameter that's passed to the `PointerReleasedCommand`. |
| 34 | + |
| 35 | +::: moniker-end |
17 | 36 |
|
18 | 37 | These properties are backed by <xref:Microsoft.Maui.Controls.BindableProperty> objects, which means that they can be targets of data bindings, and styled. |
19 | 38 |
|
20 | 39 | The <xref:Microsoft.Maui.Controls.PointerGestureRecognizer> class also defines the following events: |
21 | 40 |
|
| 41 | +::: moniker range="=net-maui-7.0" |
| 42 | + |
22 | 43 | - <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerEntered>, that's raised when the pointer enters the bounding area of the view. |
23 | 44 | - <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerExited>, that's raised when the pointer that's in the view's bounding area leaves that bounding area. |
24 | 45 | - <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerMoved>, that's raised when the pointer moves while remaining within the bounding area of the view. |
25 | 46 |
|
| 47 | +::: moniker-end |
| 48 | + |
| 49 | +::: moniker range=">=net-maui-8.0" |
| 50 | + |
| 51 | +- <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerEntered>, that's raised when the pointer enters the bounding area of the view. |
| 52 | +- <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerExited>, that's raised when the pointer that's in the view's bounding area leaves that bounding area. |
| 53 | +- <xref:Microsoft.Maui.Controls.PointerGestureRecognizer.PointerMoved>, that's raised when the pointer moves while remaining within the bounding area of the view. |
| 54 | +- `PointerPressed`, that's raised when the pointer initiates a press within the view. |
| 55 | +- `PointerReleased`, that's raised when the pointer that has previously initiated a press is released, while within the view. |
| 56 | + |
| 57 | +::: moniker-end |
| 58 | + |
26 | 59 | A <xref:Microsoft.Maui.Controls.PointerEventArgs> object accompanies all three events, and defines a `GetPosition` method that returns a `Point?` object that represents the position of the pointer when the gesture was detected. For more information about the `GetPosition` method, see [Get the gesture position](#get-the-gesture-position). |
27 | 60 |
|
28 | 61 | > [!IMPORTANT] |
|
0 commit comments