Browse Source

Remove usage of deprecated input APIs.

Steven Kirk 5 years ago
parent
commit
bc079008d1

+ 1 - 1
src/Avalonia.Controls.DataGrid/DataGridCell.cs

@@ -164,7 +164,7 @@ namespace Avalonia.Controls
             if (OwningGrid != null)
             {
                 OwningGrid.OnCellPointerPressed(new DataGridCellPointerPressedEventArgs(this, OwningRow, OwningColumn, e));
-                if (e.MouseButton == MouseButton.Left)
+                if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
                 {
                     if (!e.Handled)
                     //if (!e.Handled && OwningGrid.IsTabStop)

+ 1 - 1
src/Avalonia.Controls.DataGrid/DataGridColumnHeader.cs

@@ -457,7 +457,7 @@ namespace Avalonia.Controls
 
         private void DataGridColumnHeader_PointerPressed(object sender, PointerPressedEventArgs e)
         {
-            if (OwningColumn == null || e.Handled || !IsEnabled || e.MouseButton != MouseButton.Left)
+            if (OwningColumn == null || e.Handled || !IsEnabled || e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
             {
                 return;
             }

+ 1 - 1
src/Avalonia.Controls.DataGrid/DataGridRow.cs

@@ -786,7 +786,7 @@ namespace Avalonia.Controls
 
         private void DataGridRow_PointerPressed(PointerPressedEventArgs e)
         {
-            if(e.MouseButton != MouseButton.Left)
+            if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
             {
                 return;
             }

+ 1 - 1
src/Avalonia.Controls.DataGrid/DataGridRowGroupHeader.cs

@@ -277,7 +277,7 @@ namespace Avalonia.Controls
         //TODO TabStop
         private void DataGridRowGroupHeader_PointerPressed(PointerPressedEventArgs e)
         {
-            if (OwningGrid != null && e.MouseButton == MouseButton.Left)
+            if (OwningGrid != null && e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
             {
                 if (OwningGrid.IsDoubleClickRecordsClickOnCall(this) && !e.Handled)
                 {

+ 1 - 1
src/Avalonia.Controls.DataGrid/DataGridRowHeader.cs

@@ -164,7 +164,7 @@ namespace Avalonia.Controls.Primitives
         //TODO TabStop
         private void DataGridRowHeader_PointerPressed(object sender, PointerPressedEventArgs e)
         {
-            if(e.MouseButton != MouseButton.Left)
+            if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
             {
                 return;
             }

+ 1 - 1
src/Avalonia.Controls/Button.cs

@@ -278,7 +278,7 @@ namespace Avalonia.Controls
         {
             base.OnPointerPressed(e);
 
-            if (e.MouseButton == MouseButton.Left)
+            if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
             {
                 IsPressed = true;
                 e.Handled = true;

+ 2 - 1
src/Avalonia.Controls/Calendar/CalendarButton.cs

@@ -149,7 +149,8 @@ namespace Avalonia.Controls.Primitives
         protected override void OnPointerPressed(PointerPressedEventArgs e)
         {
             base.OnPointerPressed(e);
-            if (e.MouseButton == MouseButton.Left)
+
+            if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
                 CalendarLeftMouseButtonDown?.Invoke(this, e);
         }
 

+ 1 - 1
src/Avalonia.Controls/Calendar/CalendarDayButton.cs

@@ -206,7 +206,7 @@ namespace Avalonia.Controls.Primitives
         {
             base.OnPointerPressed(e);
 
-            if (e.MouseButton == MouseButton.Left)
+            if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
                 CalendarDayButtonMouseDown?.Invoke(this, e);
         }
 

+ 1 - 1
src/Avalonia.Controls/Calendar/DatePicker.cs

@@ -839,7 +839,7 @@ namespace Avalonia.Controls
         }
         private void Calendar_PointerPressed(object sender, PointerPressedEventArgs e)
         {
-            if (e.MouseButton == MouseButton.Left)
+            if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
             {
                 e.Handled = true;
             }

+ 3 - 1
src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs

@@ -5,6 +5,7 @@ using Avalonia.Interactivity;
 using Avalonia.LogicalTree;
 using Avalonia.Rendering;
 using Avalonia.Threading;
+using Avalonia.VisualTree;
 
 #nullable enable
 
@@ -338,8 +339,9 @@ namespace Avalonia.Controls.Platform
         protected internal virtual void PointerPressed(object sender, PointerPressedEventArgs e)
         {
             var item = GetMenuItem(e.Source as IControl);
+            var visual = (IVisual)sender;
 
-            if (e.MouseButton == MouseButton.Left && item?.HasSubMenu == true)
+            if (e.GetCurrentPoint(visual).Properties.IsLeftButtonPressed && item?.HasSubMenu == true)
             {
                 if (item.IsSubMenuOpen)
                 {

+ 1 - 1
src/Avalonia.Controls/RepeatButton.cs

@@ -88,7 +88,7 @@ namespace Avalonia.Controls
         {
             base.OnPointerPressed(e);
 
-            if (e.MouseButton == MouseButton.Left)
+            if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
             {
                 StartTimer();
             }

+ 1 - 1
src/Avalonia.Controls/TabControl.cs

@@ -240,7 +240,7 @@ namespace Avalonia.Controls
         {
             base.OnPointerPressed(e);
 
-            if (e.MouseButton == MouseButton.Left && e.Pointer.Type == PointerType.Mouse)
+            if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed && e.Pointer.Type == PointerType.Mouse)
             {
                 e.Handled = UpdateSelectionFromEventSource(e.Source);
             }

+ 1 - 1
src/Avalonia.Controls/TreeView.cs

@@ -290,7 +290,7 @@ namespace Avalonia.Controls
                 e.Handled = UpdateSelectionFromEventSource(
                     e.Source,
                     true,
-                    (e.InputModifiers & InputModifiers.Shift) != 0);
+                    (e.KeyModifiers & KeyModifiers.Shift) != 0);
             }
         }
 

+ 2 - 1
src/Avalonia.Input/FocusManager.cs

@@ -186,8 +186,9 @@ namespace Avalonia.Input
         private static void OnPreviewPointerPressed(object sender, RoutedEventArgs e)
         {
             var ev = (PointerPressedEventArgs)e;
+            var visual = (IVisual)sender;
 
-            if (sender == e.Source && ev.MouseButton == MouseButton.Left)
+            if (sender == e.Source && ev.GetCurrentPoint(visual).Properties.IsLeftButtonPressed)
             {
                 IVisual element = ev.Pointer?.Captured ?? e.Source as IInputElement;
 

+ 3 - 1
src/Avalonia.Input/Gestures.cs

@@ -1,5 +1,6 @@
 using System;
 using Avalonia.Interactivity;
+using Avalonia.VisualTree;
 
 namespace Avalonia.Input
 {
@@ -71,12 +72,13 @@ namespace Avalonia.Input
             if (ev.Route == RoutingStrategies.Bubble)
             {
                 var e = (PointerPressedEventArgs)ev;
+                var visual = (IVisual)ev.Source;
 
                 if (e.ClickCount <= 1)
                 {
                     s_lastPress = new WeakReference<IInteractive>(e.Source);
                 }
-                else if (s_lastPress != null && e.ClickCount == 2 && e.MouseButton == MouseButton.Left)
+                else if (s_lastPress != null && e.ClickCount == 2 && e.GetCurrentPoint(visual).Properties.IsLeftButtonPressed)
                 {
                     if (s_lastPress.TryGetTarget(out var target) && target == e.Source)
                     {

+ 20 - 20
tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests_Multiple.cs

@@ -669,7 +669,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
 
             target.ApplyTemplate();
             target.Presenter.ApplyTemplate();
-            _helper.Click((Interactive)target.Presenter.Panel.Children[2], modifiers: InputModifiers.Shift);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[2], modifiers: KeyModifiers.Shift);
 
             var panel = target.Presenter.Panel;
 
@@ -713,17 +713,17 @@ namespace Avalonia.Controls.UnitTests.Primitives
             VerifyAdded("Bar");
 
             receivedArgs = null;
-            _helper.Click((Interactive)target.Presenter.Panel.Children[2], modifiers: InputModifiers.Control);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[2], modifiers: KeyModifiers.Control);
 
             VerifyAdded("Baz");
 
             receivedArgs = null;
-            _helper.Click((Interactive)target.Presenter.Panel.Children[3], modifiers: InputModifiers.Control);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[3], modifiers: KeyModifiers.Control);
 
             VerifyAdded("Qux");
 
             receivedArgs = null;
-            _helper.Click((Interactive)target.Presenter.Panel.Children[1], modifiers: InputModifiers.Control);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[1], modifiers: KeyModifiers.Control);
 
             VerifyRemoved("Bar");
         }
@@ -741,14 +741,14 @@ namespace Avalonia.Controls.UnitTests.Primitives
             target.ApplyTemplate();
             target.Presenter.ApplyTemplate();
             _helper.Click((Interactive)target.Presenter.Panel.Children[1]);
-            _helper.Click((Interactive)target.Presenter.Panel.Children[2], modifiers: InputModifiers.Control);
-            _helper.Click((Interactive)target.Presenter.Panel.Children[3], modifiers: InputModifiers.Control);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[2], modifiers: KeyModifiers.Control);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[3], modifiers: KeyModifiers.Control);
 
             Assert.Equal(1, target.SelectedIndex);
             Assert.Equal("Bar", target.SelectedItem);
             Assert.Equal(new[] { "Bar", "Baz", "Qux" }, target.SelectedItems);
 
-            _helper.Click((Interactive)target.Presenter.Panel.Children[1], modifiers: InputModifiers.Control);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[1], modifiers: KeyModifiers.Control);
 
             Assert.Equal(2, target.SelectedIndex);
             Assert.Equal("Baz", target.SelectedItem);
@@ -768,12 +768,12 @@ namespace Avalonia.Controls.UnitTests.Primitives
             target.ApplyTemplate();
             target.Presenter.ApplyTemplate();
             _helper.Click((Interactive)target.Presenter.Panel.Children[1]);
-            _helper.Click((Interactive)target.Presenter.Panel.Children[2], modifiers: InputModifiers.Control);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[2], modifiers: KeyModifiers.Control);
 
             Assert.Equal(1, target.SelectedIndex);
             Assert.Equal("Bar", target.SelectedItem);
 
-            _helper.Click((Interactive)target.Presenter.Panel.Children[2], modifiers: InputModifiers.Control);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[2], modifiers: KeyModifiers.Control);
 
             Assert.Equal(1, target.SelectedIndex);
             Assert.Equal("Bar", target.SelectedItem);
@@ -792,7 +792,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
             target.ApplyTemplate();
             target.Presenter.ApplyTemplate();
             _helper.Click((Interactive)target.Presenter.Panel.Children[3]);
-            _helper.Click((Interactive)target.Presenter.Panel.Children[4], modifiers: InputModifiers.Control);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[4], modifiers: KeyModifiers.Control);
 
             var panel = target.Presenter.Panel;
 
@@ -813,7 +813,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
             target.ApplyTemplate();
             target.Presenter.ApplyTemplate();
             _helper.Click((Interactive)target.Presenter.Panel.Children[3]);
-            _helper.Click((Interactive)target.Presenter.Panel.Children[5], modifiers: InputModifiers.Shift);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[5], modifiers: KeyModifiers.Shift);
 
             var panel = target.Presenter.Panel;
 
@@ -834,7 +834,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
             target.ApplyTemplate();
             target.Presenter.ApplyTemplate();
             _helper.Click((Interactive)target.Presenter.Panel.Children[0]);
-            _helper.Click((Interactive)target.Presenter.Panel.Children[5], modifiers: InputModifiers.Shift);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[5], modifiers: KeyModifiers.Shift);
 
             var panel = target.Presenter.Panel;
 
@@ -878,12 +878,12 @@ namespace Avalonia.Controls.UnitTests.Primitives
             VerifyAdded("Bar");
 
             receivedArgs = null;
-            _helper.Click((Interactive)target.Presenter.Panel.Children[3], modifiers: InputModifiers.Shift);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[3], modifiers: KeyModifiers.Shift);
 
             VerifyAdded("Baz" ,"Qux");
 
             receivedArgs = null;
-            _helper.Click((Interactive)target.Presenter.Panel.Children[2], modifiers: InputModifiers.Shift);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[2], modifiers: KeyModifiers.Shift);
 
             VerifyRemoved("Qux");
         }
@@ -904,15 +904,15 @@ namespace Avalonia.Controls.UnitTests.Primitives
 
             Assert.Equal(new[] { "Foo" }, target.SelectedItems);
 
-            _helper.Click((Interactive)target.Presenter.Panel.Children[4], modifiers: InputModifiers.Control);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[4], modifiers: KeyModifiers.Control);
 
             Assert.Equal(new[] { "Foo", "Bar" }, target.SelectedItems);
 
-            _helper.Click((Interactive)target.Presenter.Panel.Children[3], modifiers: InputModifiers.Control);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[3], modifiers: KeyModifiers.Control);
 
             Assert.Equal(new[] { "Foo", "Bar", "Foo" }, target.SelectedItems);
 
-            _helper.Click((Interactive)target.Presenter.Panel.Children[1], modifiers: InputModifiers.Control);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[1], modifiers: KeyModifiers.Control);
 
             Assert.Equal(new[] { "Foo", "Bar", "Foo", "Bar" }, target.SelectedItems);
         }
@@ -1174,7 +1174,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
             target.ApplyTemplate();
             target.Presenter.ApplyTemplate();
             _helper.Click((Interactive)target.Presenter.Panel.Children[0]);
-            _helper.Click((Interactive)target.Presenter.Panel.Children[1], modifiers: InputModifiers.Shift);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[1], modifiers: KeyModifiers.Shift);
 
             Assert.Equal(2, target.SelectedItems.Count);
 
@@ -1224,7 +1224,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
             target.Presenter.ApplyTemplate();
 
             _helper.Click((Interactive)target.Presenter.Panel.Children[0]);
-            _helper.Click((Interactive)target.Presenter.Panel.Children[2], MouseButton.Right, modifiers: InputModifiers.Shift);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[2], MouseButton.Right, modifiers: KeyModifiers.Shift);
 
             Assert.Equal(1, target.SelectedItems.Count);
         }
@@ -1244,7 +1244,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
             target.Presenter.ApplyTemplate();
 
             _helper.Click((Interactive)target.Presenter.Panel.Children[0]);
-            _helper.Click((Interactive)target.Presenter.Panel.Children[2], MouseButton.Right, modifiers: InputModifiers.Control);
+            _helper.Click((Interactive)target.Presenter.Panel.Children[2], MouseButton.Right, modifiers: KeyModifiers.Control);
 
             Assert.Equal(1, target.SelectedItems.Count);
         }

+ 22 - 22
tests/Avalonia.Controls.UnitTests/TreeViewTests.cs

@@ -167,7 +167,7 @@ namespace Avalonia.Controls.UnitTests
 
             Assert.True(container.IsSelected);
 
-            _mouse.Click(container, modifiers: InputModifiers.Control);
+            _mouse.Click(container, modifiers: KeyModifiers.Control);
 
             Assert.Null(target.SelectedItem);
             Assert.False(container.IsSelected);
@@ -202,7 +202,7 @@ namespace Avalonia.Controls.UnitTests
 
             Assert.True(container1.IsSelected);
 
-            _mouse.Click(container2, modifiers: InputModifiers.Control);
+            _mouse.Click(container2, modifiers: KeyModifiers.Control);
             
             Assert.Equal(item2, target.SelectedItem);
             Assert.False(container1.IsSelected);
@@ -234,15 +234,15 @@ namespace Avalonia.Controls.UnitTests
             var item1Container = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(item1);
             var item2Container = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(item2);
 
-            ClickContainer(item1Container, InputModifiers.Control);
+            ClickContainer(item1Container, KeyModifiers.Control);
             Assert.True(item1Container.IsSelected);
 
-            ClickContainer(item2Container, InputModifiers.Control);
+            ClickContainer(item2Container, KeyModifiers.Control);
             Assert.True(item2Container.IsSelected);
 
             Assert.Equal(new[] {item1, item2}, target.Selection.SelectedItems.OfType<Node>());
 
-            ClickContainer(item1Container, InputModifiers.Control);
+            ClickContainer(item1Container, KeyModifiers.Control);
             Assert.False(item1Container.IsSelected);
 
             Assert.DoesNotContain(item1, target.Selection.SelectedItems.OfType<Node>());
@@ -273,11 +273,11 @@ namespace Avalonia.Controls.UnitTests
             var fromContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(from);
             var toContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(to);
 
-            ClickContainer(fromContainer, InputModifiers.None);
+            ClickContainer(fromContainer, KeyModifiers.None);
 
             Assert.True(fromContainer.IsSelected);
 
-            ClickContainer(toContainer, InputModifiers.Shift);
+            ClickContainer(toContainer, KeyModifiers.Shift);
             AssertChildrenSelected(target, rootNode);
         }
 
@@ -306,11 +306,11 @@ namespace Avalonia.Controls.UnitTests
             var fromContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(from);
             var toContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(to);
 
-            ClickContainer(fromContainer, InputModifiers.None);
+            ClickContainer(fromContainer, KeyModifiers.None);
 
             Assert.True(fromContainer.IsSelected);
 
-            ClickContainer(toContainer, InputModifiers.Shift);
+            ClickContainer(toContainer, KeyModifiers.Shift);
             AssertChildrenSelected(target, rootNode);
         }
 
@@ -339,12 +339,12 @@ namespace Avalonia.Controls.UnitTests
             var fromContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(from);
             var toContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(to);
 
-            ClickContainer(fromContainer, InputModifiers.None);
+            ClickContainer(fromContainer, KeyModifiers.None);
 
-            ClickContainer(toContainer, InputModifiers.Shift);
+            ClickContainer(toContainer, KeyModifiers.Shift);
             AssertChildrenSelected(target, rootNode);
 
-            ClickContainer(fromContainer, InputModifiers.None);
+            ClickContainer(fromContainer, KeyModifiers.None);
 
             Assert.True(fromContainer.IsSelected);
 
@@ -660,8 +660,8 @@ namespace Avalonia.Controls.UnitTests
                 var fromContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(from);
                 var toContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(to);
 
-                ClickContainer(fromContainer, InputModifiers.None);
-                ClickContainer(toContainer, InputModifiers.Shift);
+                ClickContainer(fromContainer, KeyModifiers.None);
+                ClickContainer(toContainer, KeyModifiers.Shift);
 
                 var keymap = AvaloniaLocator.Current.GetService<PlatformHotkeyConfiguration>();
                 var selectAllGesture = keymap.SelectAll.First();
@@ -706,8 +706,8 @@ namespace Avalonia.Controls.UnitTests
                 var fromContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(from);
                 var toContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(to);
 
-                ClickContainer(fromContainer, InputModifiers.None);
-                ClickContainer(toContainer, InputModifiers.Shift);
+                ClickContainer(fromContainer, KeyModifiers.None);
+                ClickContainer(toContainer, KeyModifiers.Shift);
 
                 var keymap = AvaloniaLocator.Current.GetService<PlatformHotkeyConfiguration>();
                 var selectAllGesture = keymap.SelectAll.First();
@@ -778,8 +778,8 @@ namespace Avalonia.Controls.UnitTests
             var toContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(to);
             var thenContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(then);
 
-            ClickContainer(fromContainer, InputModifiers.None);
-            ClickContainer(toContainer, InputModifiers.Shift);
+            ClickContainer(fromContainer, KeyModifiers.None);
+            ClickContainer(toContainer, KeyModifiers.Shift);
 
             Assert.Equal(2, target.Selection.SelectedItems.Count);
 
@@ -813,7 +813,7 @@ namespace Avalonia.Controls.UnitTests
             var toContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(to);
 
             _mouse.Click(fromContainer);
-            _mouse.Click(toContainer, MouseButton.Right, modifiers: InputModifiers.Shift);
+            _mouse.Click(toContainer, MouseButton.Right, modifiers: KeyModifiers.Shift);
 
             Assert.Equal(1, target.Selection.SelectedItems.Count);
         }
@@ -843,7 +843,7 @@ namespace Avalonia.Controls.UnitTests
             var toContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(to);
 
             _mouse.Click(fromContainer);
-            _mouse.Click(toContainer, MouseButton.Right, modifiers: InputModifiers.Control);
+            _mouse.Click(toContainer, MouseButton.Right, modifiers: KeyModifiers.Control);
 
             Assert.Equal(1, target.Selection.SelectedItems.Count);
         }
@@ -963,7 +963,7 @@ namespace Avalonia.Controls.UnitTests
                 ApplyTemplates(target);
 
                 _mouse.Click(GetItem(target, 0));
-                _mouse.Click(GetItem(target, 1), modifiers: InputModifiers.Shift);
+                _mouse.Click(GetItem(target, 1), modifiers: KeyModifiers.Shift);
             }
         }
 
@@ -1170,7 +1170,7 @@ namespace Avalonia.Controls.UnitTests
             }
         }
 
-        void ClickContainer(IControl container, InputModifiers modifiers)
+        void ClickContainer(IControl container, KeyModifiers modifiers)
         {
             _mouse.Click(container, modifiers: modifiers);
         }

+ 2 - 2
tests/Avalonia.Controls.UnitTests/Utils/HotKeyManagerTests.cs

@@ -21,8 +21,8 @@ namespace Avalonia.Controls.UnitTests.Utils
                     .Bind<IWindowingPlatform>().ToConstant(new WindowingPlatformMock())
                     .Bind<IStyler>().ToConstant(styler.Object);
 
-                var gesture1 = new KeyGesture(Key.A, InputModifiers.Control);
-                var gesture2 = new KeyGesture(Key.B, InputModifiers.Control);
+                var gesture1 = new KeyGesture(Key.A, KeyModifiers.Control);
+                var gesture2 = new KeyGesture(Key.B, KeyModifiers.Control);
 
                 var tl = new Window();
                 var button = new Button();

+ 25 - 22
tests/Avalonia.UnitTests/MouseTestHelper.cs

@@ -6,19 +6,25 @@ namespace Avalonia.UnitTests
 {
     public class MouseTestHelper
     {
-        private Pointer _pointer = new Pointer(Pointer.GetNextFreeId(), PointerType.Mouse, true);
+        private readonly Pointer _pointer = new Pointer(Pointer.GetNextFreeId(), PointerType.Mouse, true);
         private ulong _nextStamp = 1;
         private ulong Timestamp() => _nextStamp++;
 
-        private InputModifiers _pressedButtons;
+        private RawInputModifiers _pressedButtons;
         public IInputElement Captured => _pointer.Captured;
 
-        InputModifiers Convert(MouseButton mouseButton)
-            => (mouseButton == MouseButton.Left ? InputModifiers.LeftMouseButton
-                : mouseButton == MouseButton.Middle ? InputModifiers.MiddleMouseButton
-                : mouseButton == MouseButton.Right ? InputModifiers.RightMouseButton : InputModifiers.None);
-        
-        int ButtonCount(PointerPointProperties props)
+        private RawInputModifiers Convert(MouseButton mouseButton)
+        {
+            return mouseButton switch
+            {
+                MouseButton.Left => RawInputModifiers.LeftMouseButton,
+                MouseButton.Right => RawInputModifiers.RightMouseButton,
+                MouseButton.Middle => RawInputModifiers.MiddleMouseButton,
+                _ => RawInputModifiers.None,
+            };
+        }
+
+        private int ButtonCount(PointerPointProperties props)
         {
             var rv = 0;
             if (props.IsLeftButtonPressed)
@@ -32,17 +38,14 @@ namespace Avalonia.UnitTests
 
         private MouseButton _pressedButton;
 
-        KeyModifiers GetModifiers(InputModifiers modifiers) =>
-            (KeyModifiers)((int)modifiers & (int)RawInputModifiers.KeyboardMask);
-        
         public void Down(IInteractive target, MouseButton mouseButton = MouseButton.Left, Point position = default,
-            InputModifiers modifiers = default, int clickCount = 1)
+            KeyModifiers modifiers = default, int clickCount = 1)
         {
             Down(target, target, mouseButton, position, modifiers, clickCount);
         }
 
         public void Down(IInteractive target, IInteractive source, MouseButton mouseButton = MouseButton.Left, 
-            Point position = default, InputModifiers modifiers = default, int clickCount = 1)
+            Point position = default, KeyModifiers modifiers = default, int clickCount = 1)
         {
             _pressedButtons |= Convert(mouseButton);
             var props = new PointerPointProperties((RawInputModifiers)_pressedButtons,
@@ -57,23 +60,23 @@ namespace Avalonia.UnitTests
                 _pressedButton = mouseButton;
                 _pointer.Capture((IInputElement)target);
                 source.RaiseEvent(new PointerPressedEventArgs(source, _pointer, (IVisual)source, position, Timestamp(), props,
-                    GetModifiers(modifiers), clickCount));
+                    modifiers, clickCount));
             }
         }
 
-        public void Move(IInteractive target, in Point position, InputModifiers modifiers = default) => Move(target, target, position, modifiers);
-        public void Move(IInteractive target, IInteractive source, in Point position, InputModifiers modifiers = default)
+        public void Move(IInteractive target, in Point position, KeyModifiers modifiers = default) => Move(target, target, position, modifiers);
+        public void Move(IInteractive target, IInteractive source, in Point position, KeyModifiers modifiers = default)
         {
             target.RaiseEvent(new PointerEventArgs(InputElement.PointerMovedEvent, source, _pointer, (IVisual)target, position,
-                Timestamp(), new PointerPointProperties((RawInputModifiers)_pressedButtons, PointerUpdateKind.Other), GetModifiers(modifiers)));
+                Timestamp(), new PointerPointProperties((RawInputModifiers)_pressedButtons, PointerUpdateKind.Other), modifiers));
         }
 
         public void Up(IInteractive target, MouseButton mouseButton = MouseButton.Left, Point position = default,
-            InputModifiers modifiers = default)
+            KeyModifiers modifiers = default)
             => Up(target, target, mouseButton, position, modifiers);
         
         public void Up(IInteractive target, IInteractive source, MouseButton mouseButton = MouseButton.Left,
-            Point position = default, InputModifiers modifiers = default)
+            Point position = default, KeyModifiers modifiers = default)
         {
             var conv = Convert(mouseButton);
             _pressedButtons = (_pressedButtons | conv) ^ conv;
@@ -85,7 +88,7 @@ namespace Avalonia.UnitTests
             if (ButtonCount(props) == 0)
             {
                 target.RaiseEvent(new PointerReleasedEventArgs(source, _pointer, (IVisual)target, position,
-                    Timestamp(), props, GetModifiers(modifiers), _pressedButton));
+                    Timestamp(), props, modifiers, _pressedButton));
                 _pointer.Capture(null);
             }
             else
@@ -93,10 +96,10 @@ namespace Avalonia.UnitTests
         }
 
         public void Click(IInteractive target, MouseButton button = MouseButton.Left, Point position = default,
-            InputModifiers modifiers = default)
+            KeyModifiers modifiers = default)
             => Click(target, target, button, position, modifiers);
         public void Click(IInteractive target, IInteractive source, MouseButton button = MouseButton.Left, 
-            Point position = default, InputModifiers modifiers = default)
+            Point position = default, KeyModifiers modifiers = default)
         {
             Down(target, source, button, position, modifiers);
             Up(target, source, button, position, modifiers);