-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathIssues16561.xaml.cs
53 lines (44 loc) · 1.2 KB
/
Issues16561.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;
using Microsoft.Maui.Platform;
namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 16561, "Quick single taps on Android have wrong second tap location", PlatformAffected.Android)]
public partial class Issue16561 : ContentPage
{
int _taps;
public Issue16561()
{
InitializeComponent();
var tapGesture = new TapGestureRecognizer();
tapGesture.Tapped += TapHandler;
TapArea.GestureRecognizers.Add(tapGesture);
}
void TapHandler(object sender, TappedEventArgs e)
{
var pos = e.GetPosition(TapArea);
if (pos == null)
{
Tap1Label.Text = $"Error, could not get tap position";
return;
}
#if ANDROID
// Adjust the results for display density, so they make sense to the
// Appium test consuming this.
var x = this.Handler.MauiContext.Context.ToPixels(pos.Value.X);
var y = this.Handler.MauiContext.Context.ToPixels(pos.Value.Y);
pos = new(x, y);
#endif
if (_taps % 2 == 0)
{
Tap1Label.Text = $"{pos.Value.X}, {pos.Value.Y}";
}
else
{
Tap2Label.Text = $"{pos.Value.X}, {pos.Value.Y}";
}
_taps += 1;
}
}
}