Input event handling in WinUI Map and MapItem.

This commit is contained in:
ClemensFischer 2025-03-19 15:27:27 +01:00
parent 4cfaff7ba8
commit 86f307359f
7 changed files with 18 additions and 23 deletions

View file

@ -21,7 +21,7 @@ namespace MapControl
DependencyPropertyHelper.Register<Map, double>(nameof(MouseWheelZoomDelta), 0.25);
private double mouseWheelDelta;
private bool? manipulationEnabled;
private bool manipulationEnabled;
public Map()
{
@ -34,7 +34,6 @@ namespace MapControl
ManipulationDelta += OnManipulationDelta;
ManipulationCompleted += OnManipulationCompleted;
PointerPressed += OnPointerPressed;
PointerMoved += OnPointerMoved;
PointerWheelChanged += OnPointerWheelChanged;
}
@ -50,7 +49,7 @@ namespace MapControl
private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
if (manipulationEnabled.HasValue && manipulationEnabled.Value)
if (manipulationEnabled)
{
if (e.PointerDeviceType == PointerDeviceType.Mouse)
{
@ -65,7 +64,7 @@ namespace MapControl
private void OnManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
manipulationEnabled = null;
manipulationEnabled = false;
}
private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
@ -77,17 +76,6 @@ namespace MapControl
e.KeyModifiers == VirtualKeyModifiers.None;
}
private void OnPointerMoved(object sender, PointerRoutedEventArgs e)
{
// Set manipulationEnabled when no PointerPressed was received.
//
if (!manipulationEnabled.HasValue &&
e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
{
manipulationEnabled = e.KeyModifiers == VirtualKeyModifiers.None;
}
}
private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)
{
if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)