Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
In 1.2 I have several ImageButtons that I have created custom touch listeners for by inheriting from View.IOnTouchListener, I then instantiate an instance of this class, pass it into SetOnTouchListener, I do all of this on the OnCreate call in the Activity.
I haven't had a chance to pull out this behavior into an empty project and isolate the issue, but when I reverted back to 1.2 and made no code changes it all started working again. The TouchListener OnTouch event never fires, I set a breakpoint on it and at no point does it drop into this code. It seems to ignore it completely...
Could I please get a sample for testing? Writing reproduction code greatly slows things down, and is time better spent investigating and fixing the dozens of other filed bugs... :-)
What I do have is a test which does:
var textview = new TextView (this);
textview.Touch += OnTouch;
and my OnTouch method is invoked.
Ok I will get a sample to you when I get a chance to isolate the issue...
Created attachment 832 [details]
Attached an Example where the issue is Isolated
The example attached is very simple, it uses a ImageButton, attaches a View.IOnTouchListener which fires off a couple ToastMessages. I would encourage you to run it using 1.2 first to see correct behavior, and then run it in 1.9.2 to see incorrect behavior (does nothing).
I don't know why it even worked in 1.2, but it certainly shouldn't have. :-)
When implementing IJavaObject, you must inherit Java.Lang.Object:
If we fix MyTouchListener to inherit from Java.Lang.Object, the sample works:
public class MyTouchListener : Java.Lang.Object, View.IOnTouchListener
public event EventHandler<EventArgs> OnClick;
public MyTouchListener(Context ctx)
context = ctx;
public bool OnTouch(View v, MotionEvent e)
Toast.MakeText(context, "Down", ToastLength.Short).Show();
Toast.MakeText(context, "Up", ToastLength.Short).Show();
private void Clicked()
if(OnClick != null)