From bc8f1ce6033732d0076b65661db5081fc19ccfa8 Mon Sep 17 00:00:00 2001 From: Clemens Date: Mon, 24 Jan 2022 23:29:35 +0100 Subject: [PATCH] Fixed touch input in Map.WinUI.cs --- MapControl/WinUI/Map.WinUI.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/MapControl/WinUI/Map.WinUI.cs b/MapControl/WinUI/Map.WinUI.cs index 40acb8e3..4da14be2 100644 --- a/MapControl/WinUI/Map.WinUI.cs +++ b/MapControl/WinUI/Map.WinUI.cs @@ -4,9 +4,11 @@ using System; #if WINUI +using Microsoft.UI.Input; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Input; #else +using Windows.Devices.Input; using Windows.UI.Xaml; using Windows.UI.Xaml.Input; #endif @@ -57,7 +59,8 @@ namespace MapControl private void OnPointerPressed(object sender, PointerRoutedEventArgs e) { - if (CapturePointer(e.Pointer)) + if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse && + CapturePointer(e.Pointer)) { mousePosition = e.GetCurrentPoint(this).Position; } @@ -65,7 +68,8 @@ namespace MapControl private void OnPointerReleased(object sender, PointerRoutedEventArgs e) { - if (mousePosition.HasValue) + if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse && + mousePosition.HasValue) { mousePosition = null; ReleasePointerCaptures(); @@ -74,7 +78,11 @@ namespace MapControl private void OnPointerMoved(object sender, PointerRoutedEventArgs e) { - if (mousePosition.HasValue) + // Perform translation by explicit Mouse input because with Manipulation pointer capture is + // lost when Map content changes, e.g. when a MapTileLayer or WmsImageLayer loads new images. + + if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse && + mousePosition.HasValue) { Point position = e.GetCurrentPoint(this).Position; var translation = position - mousePosition.Value;