I want to know when a button is pressed and when a button is released. I seen this example where the gestures are captured for a label here:
http://arteksoftware.com/gesture-recognizers-with-xamarin-forms/
The example works great. I tried the same for a Button but the event handlers are never fired. Any ideas why? Below is the button render;
` using Xamarin.Forms.Platform.Android;
using Xamarin.Forms;
using XamarinFormsGestureRecognizers;
using XamarinFormsGestureRecognizers.Droid;
using Android.Views;
[assembly: ExportRenderer (typeof (OnTouchButton), typeof (OnTouchButtonRenderer))]
namespace XamarinFormsGestureRecognizers.Droid
{
public class OnTouchButtonRenderer : ButtonRenderer
{
private readonly FancyGestureListener _listener;
private readonly GestureDetector _detector;
public OnTouchButtonRenderer()
{
_listener = new FancyGestureListener ();
_detector = new GestureDetector (_listener);
}
protected override void OnElementChanged (ElementChangedEventArgs<Button> e)
{
base.OnElementChanged (e);
if (e.NewElement == null)
{
this.GenericMotion -= HandleGenericMotion;
this.Touch -= HandleTouch;
}
if (e.OldElement == null) {
this.GenericMotion += HandleGenericMotion;
this.Touch += HandleTouch;
}
}
void HandleTouch (object sender, TouchEventArgs e)
{
System.Diagnostics.Debug.Write("Button push");
_detector.OnTouchEvent (e.Event);
}
void HandleGenericMotion (object sender, GenericMotionEventArgs e)
{
System.Diagnostics.Debug.Write("Button motion");
_detector.OnTouchEvent (e.Event);
}
}
}
`