Browse Source
Merge pull request #4504 from jp2masa/tapped-left-button
Fire Tapped only on left button click
pull/4573/head
Steven Kirk
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
8 additions and
6 deletions
-
src/Avalonia.Input/Gestures.cs
-
tests/Avalonia.Input.UnitTests/GesturesTests.cs
|
|
|
@ -96,8 +96,11 @@ namespace Avalonia.Input |
|
|
|
|
|
|
|
if (s_lastPress.TryGetTarget(out var target) && target == e.Source) |
|
|
|
{ |
|
|
|
var et = e.InitialPressMouseButton != MouseButton.Right ? TappedEvent : RightTappedEvent; |
|
|
|
e.Source.RaiseEvent(new RoutedEventArgs(et)); |
|
|
|
if (e.InitialPressMouseButton == MouseButton.Left || e.InitialPressMouseButton == MouseButton.Right) |
|
|
|
{ |
|
|
|
var et = e.InitialPressMouseButton != MouseButton.Right ? TappedEvent : RightTappedEvent; |
|
|
|
e.Source.RaiseEvent(new RoutedEventArgs(et)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -1,10 +1,9 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Input; |
|
|
|
using Avalonia.UnitTests; |
|
|
|
using Xunit; |
|
|
|
|
|
|
|
namespace Avalonia.Interactivity.UnitTests |
|
|
|
namespace Avalonia.Input.UnitTests |
|
|
|
{ |
|
|
|
public class GesturesTests |
|
|
|
{ |
|
|
|
@ -45,7 +44,7 @@ namespace Avalonia.Interactivity.UnitTests |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Tapped_Should_Be_Raised_For_Middle_Button() |
|
|
|
public void Tapped_Should_Not_Be_Raised_For_Middle_Button() |
|
|
|
{ |
|
|
|
Border border = new Border(); |
|
|
|
var decorator = new Decorator |
|
|
|
@ -58,7 +57,7 @@ namespace Avalonia.Interactivity.UnitTests |
|
|
|
|
|
|
|
_mouse.Click(border, MouseButton.Middle); |
|
|
|
|
|
|
|
Assert.True(raised); |
|
|
|
Assert.False(raised); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
|