Bug 26281 - NSEvent Methods given non Event objects
Summary: NSEvent Methods given non Event objects
Status: RESOLVED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 1.11.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: master
Assignee: Timothy Risi
URL:
Depends on:
Blocks:
 
Reported: 2015-01-22 08:58 UTC by David Lilley
Modified: 2016-02-02 21:23 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Screenshot Subclassed NSTextview pretending to be NSEvent (106.20 KB, image/png)
2015-01-22 08:58 UTC, David Lilley
Details
Constrained example csproj (17.29 KB, application/zip)
2015-07-23 14:42 UTC, C Noel
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
RESOLVED FIXED

Description David Lilley 2015-01-22 08:58:40 UTC
Created attachment 9445 [details]
Screenshot Subclassed NSTextview pretending to be NSEvent

I keep getting weird things I have subclassed being passed to NSEvent methods

PerformKeyEquivalent( NSEvent aEvent) on subclassed TextField being passed not NSEvent but NSView

or 

public override void SendEvent(NSEvent aEvent) on Window being passed subclassed NSTextView.

See Picture Attached.
Comment 1 Chris Hamons 2015-02-20 17:35:55 UTC
@David.

Could you attach an example showing this and what version of Xamarin Studio / Xamarin.Mac you are using.

I just tried and i'm seeing seems pretty reasonable:

https://www.dropbox.com/s/tojmhrly3h1jxmz/Screen%20Shot%202015-02-20%20at%204.35.18%20PM.png?dl=0
Comment 2 David Lilley 2015-07-22 05:30:02 UTC
Does not seem to be a issue now. I believe it might to do with GC, Since I have done a lot of clean up of removing Events when removing the View, It no longer shows.
Comment 4 C Noel 2015-07-23 14:42:26 UTC
Created attachment 12195 [details]
Constrained example csproj

I am attaching a constrained example that reproduces this bug. In order to use, build and run this example. Watch the Console output. After seeing "Reload Data" a couple times, type into the keyboard. You will see in the Console Output that our override for  NSWindow.SendEvent is receiving invalid NSEvents.

You can reproduce a worse version of the same error by dragging the window using the image on the right. In this case, the NextEvent function throws an exception because it is trying to cast an invalid NSEvent.
Comment 5 C Noel 2015-07-23 16:55:40 UTC
Also: I just rolled back to Xamarin.Mac 2.0.1.64 and this stopped happening.
Comment 6 Timothy Risi 2015-07-23 17:53:05 UTC
I was able to reproduce the issue on 2.0.2.35.  I'll look into it.
Comment 7 David Lilley 2015-07-24 04:05:09 UTC
I was curious myself and noticed the following point

NSLabelCellView is using Layer, which should be no problem. 
but comment the following out and its no problem. Not sure if that helps ?

//			WantsLayer = true;
//			Layer.BackgroundColor = NSColor.White.CGColor;

Ok you don't; need it in the example but perhaps a work around is to paint the background on the DrawRect Method ?
Comment 8 C Noel 2015-09-16 14:08:07 UTC
Just wondering what the progress is on this. The 2.3 builds in the Alpha channel are still exhibiting this bug, which means that we won't be able to release for El Capitan!
Comment 9 Chris Hamons 2016-02-02 21:23:29 UTC
Sorry or the long delay in response. 

This issue appears to be fixed in the latest XM in stable. Please reopen with steps to reproduce if you are still running into trouble.