-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
PointerEventArgs.cs
43 lines (37 loc) · 1.22 KB
/
PointerEventArgs.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using Microsoft.Maui.Graphics;
namespace Microsoft.Maui.Controls
{
/// <summary>
/// Arguments for PointerGestureRecognizer events.
/// </summary>
public class PointerEventArgs : EventArgs
{
Func<IElement?, Point?>? _getPosition;
/// <summary>
/// Gets the platform-specific arguments associated with the <see cref="PointerEventArgs"/>.
/// </summary>
public PlatformPointerEventArgs? PlatformArgs { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="PointerEventArgs"/> class.
/// </summary>
public PointerEventArgs()
{
}
internal PointerEventArgs(Func<IElement?, Point?>? getPosition, PlatformPointerEventArgs? args = null)
{
_getPosition = getPosition;
PlatformArgs = args;
}
/// <summary>
/// When overridden in a derived class, gets the position of the pointer.
/// </summary>
/// <remarks>
/// Gets the position of the pointer relative to the element by default.
/// </remarks>
/// <param name="relativeTo">Where the pointer will be measured from.</param>
/// <returns>The position relative to the <see cref="Element"/>.</returns>
public virtual Point? GetPosition(Element? relativeTo) =>
_getPosition?.Invoke(relativeTo);
}
}