blob: 13f2fffa3ce5af16306257ed49030586552a7adc (
plain)
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
|
namespace Xamarin.Forms.Platform.Android
{
public static class VisualElementExtensions
{
public static bool ShouldBeMadeClickable(this View view)
{
var shouldBeClickable = false;
for (var i = 0; i < view.GestureRecognizers.Count; i++)
{
IGestureRecognizer gesture = view.GestureRecognizers[i];
if (gesture is TapGestureRecognizer || gesture is PinchGestureRecognizer || gesture is PanGestureRecognizer)
{
shouldBeClickable = true;
break;
}
}
// do some evil
// This is required so that a layout only absorbs click events if it is not fully transparent
// However this is not desirable behavior in a ViewCell because it prevents the ViewCell from activating
if (view is Layout && view.BackgroundColor != Color.Transparent && view.BackgroundColor != Color.Default)
{
Element parent = view.RealParent;
var skip = false;
while (parent != null)
{
if (parent is ViewCell)
{
skip = true;
break;
}
parent = parent.RealParent;
}
if (!skip)
shouldBeClickable = true;
}
return shouldBeClickable;
}
}
}
|