mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Input event handling in WinUI Map and MapItem
This commit is contained in:
parent
86f307359f
commit
58ce17db46
|
|
@ -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,6 +34,7 @@ namespace MapControl
|
|||
ManipulationDelta += OnManipulationDelta;
|
||||
ManipulationCompleted += OnManipulationCompleted;
|
||||
PointerPressed += OnPointerPressed;
|
||||
PointerMoved += OnPointerMoved;
|
||||
PointerWheelChanged += OnPointerWheelChanged;
|
||||
}
|
||||
|
||||
|
|
@ -49,7 +50,7 @@ namespace MapControl
|
|||
|
||||
private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
|
||||
{
|
||||
if (manipulationEnabled)
|
||||
if (manipulationEnabled.HasValue && manipulationEnabled.Value)
|
||||
{
|
||||
if (e.PointerDeviceType == PointerDeviceType.Mouse)
|
||||
{
|
||||
|
|
@ -64,7 +65,7 @@ namespace MapControl
|
|||
|
||||
private void OnManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
|
||||
{
|
||||
manipulationEnabled = false;
|
||||
manipulationEnabled = null;
|
||||
}
|
||||
|
||||
private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
|
||||
|
|
@ -76,6 +77,17 @@ 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)
|
||||
|
|
|
|||
|
|
@ -45,11 +45,6 @@ namespace MapControl
|
|||
pointerPressedPosition = e.GetCurrentPoint(null).Position;
|
||||
|
||||
base.OnPointerPressed(e);
|
||||
|
||||
// Unsetting e.Handled enables PointerPressed event handlers
|
||||
// and PointerPressed handling in class Map.
|
||||
//
|
||||
e.Handled = false;
|
||||
}
|
||||
|
||||
protected override void OnPointerReleased(PointerRoutedEventArgs e)
|
||||
|
|
@ -71,9 +66,7 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
// Unsetting e.Handled enables PointerReleased event handlers.
|
||||
//
|
||||
e.Handled = false;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
|
|
|
|||
Loading…
Reference in a new issue