mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Revert to default ListBox mouse event handling
This commit is contained in:
parent
584dcd7bb4
commit
70fd58d418
|
|
@ -10,20 +10,17 @@
|
|||
(item, oldValue, newValue) => item.UpdateMapTransform(newValue));
|
||||
|
||||
/// <summary>
|
||||
/// Replaces ListBoxItem pointer event handling by not calling base.OnPointerPressed.
|
||||
/// Setting e.Handled = true generates a PointerReleased event in the parent MapItemsControl,
|
||||
/// which resembles the behavior of the ListBox base class.
|
||||
/// Prevent range selection by Shift+PointerPressed.
|
||||
/// </summary>
|
||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
||||
{
|
||||
if (!e.Handled)
|
||||
if (e.KeyModifiers.HasFlag(KeyModifiers.Shift))
|
||||
{
|
||||
e.Handled = true;
|
||||
|
||||
if (ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
|
||||
}
|
||||
else
|
||||
{
|
||||
mapItemsControl.OnItemClicked(this, e.KeyModifiers.HasFlag(KeyModifiers.Control));
|
||||
}
|
||||
base.OnPointerPressed(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,41 +78,5 @@ namespace MapControl
|
|||
{
|
||||
SelectItemsByPosition(rect.Contains);
|
||||
}
|
||||
|
||||
protected internal void OnItemClicked(MapItem mapItem, bool controlKeyPressed)
|
||||
{
|
||||
var item = ItemFromContainer(mapItem);
|
||||
|
||||
if (SelectionMode == SelectionMode.Single)
|
||||
{
|
||||
if (SelectedItem != item)
|
||||
{
|
||||
SelectedItem = item;
|
||||
}
|
||||
else if (controlKeyPressed)
|
||||
{
|
||||
SelectedItem = null;
|
||||
}
|
||||
}
|
||||
else if (
|
||||
#if !AVALONIA
|
||||
SelectionMode == SelectionMode.Multiple ||
|
||||
#endif
|
||||
controlKeyPressed)
|
||||
{
|
||||
if (SelectedItems.Contains(item))
|
||||
{
|
||||
SelectedItems.Remove(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedItems.Add(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ResetSelectedItems(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace MapControl
|
||||
|
|
@ -19,31 +18,18 @@ namespace MapControl
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces ListBoxItem mouse event handling by not calling base.OnMouseLeftButtonDown.
|
||||
/// Setting e.Handled = true generates a MouseLeftButtonUp event in the parent MapItemsControl,
|
||||
/// which resembles the behavior of the ListBox base class.
|
||||
/// Prevent range selection by Shift+MouseLeftButtonDown.
|
||||
/// </summary>
|
||||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
if (!e.Handled)
|
||||
if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
|
||||
{
|
||||
e.Handled = true;
|
||||
|
||||
if (ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
|
||||
}
|
||||
else
|
||||
{
|
||||
mapItemsControl.OnItemClicked(this, Keyboard.Modifiers.HasFlag(ModifierKeys.Control));
|
||||
base.OnMouseLeftButtonDown(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces ListBoxItem mouse event handling by not calling base.OnMouseRightButtonDown.
|
||||
/// Setting e.Handled = true generates a MouseRightButtonUp event in the parent MapItemsControl,
|
||||
/// which resembles the behavior of the ListBox base class.
|
||||
/// </summary>
|
||||
protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
OnMouseLeftButtonDown(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
using Windows.System;
|
||||
#if UWP
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
#else
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
#endif
|
||||
|
|
@ -34,21 +32,17 @@ namespace MapControl
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces ListBoxItem pointer event handling by not calling base.OnPointerPressed.
|
||||
/// Setting e.Handled = true generates a PointerReleased event in the parent MapItemsControl,
|
||||
/// which differs from the behavior of the ListBox base class, where neither a PointerPressed
|
||||
/// nor a PointerReleased is generated.
|
||||
/// Prevent range selection by Shift+PointerPressed.
|
||||
/// </summary>
|
||||
protected override void OnPointerPressed(PointerRoutedEventArgs e)
|
||||
{
|
||||
if (!e.Handled)
|
||||
if (e.KeyModifiers.HasFlag(VirtualKeyModifiers.Shift))
|
||||
{
|
||||
e.Handled = true;
|
||||
|
||||
if (ItemsControl.ItemsControlFromItemContainer(this) is MapItemsControl mapItemsControl)
|
||||
{
|
||||
mapItemsControl.OnItemClicked(this, e.KeyModifiers.HasFlag(VirtualKeyModifiers.Control));
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnPointerPressed(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue