Avalonia operates on the abstraction called pointer devices. These devices including, but not limited to mouse, touch, pen etc. Each control in Avalonia provides following events which allow developer to subscribe to the pointer device movements, clicks and wheel movements:
Example how to react on pointer button pressed.
control.PointerPressed += (args) =>
var point = args.GetCurrentPoint();
var x = point.Position.X;
var y = point.Position.Y;
// left button pressed
// right button pressed
In the example above, coordinates
yare relatively to the window origin. If you want coordinates relative to the specific control, you may pass it to
PointerEventArgs.GetCurrentPointmethod like this:
var pointControlCoords = args.GetCurrentPoint(control);
Each control also has special gesture events: Tapped and DoubleTapped. Tapped is raised, when pointer was pressed on the control and then released. While DoubleTapped is raised after pointer was pressed twice on the same place. Allowed size (distance between first and second "tap") and time (delay between them) depend on the platform and usually is bigger for the touch devices.