[Cocoa-sharp] NSEvent:mouseLocation and static methods

Pedro Gutierrez pgutierrez at etsii.upm.es
Mon Mar 12 05:20:09 EDT 2007


Hi,

I've been playing with cocoa-sharp for the last two weeks and got an  
OpenGl context working with cocoa# and Tao Framework 2.0RC1 (it  
works!). Right now I'm trying to process mouse clicks but I can't get  
the mouse position.

The mouseDown event for the Cocoa.OpenGLView is fired when I click  
inside the OpenGlView, and I can read some of the properties of the  
NSEvent object (received as a Cocoa.Object because Cocoa.Event does  
not exist). The problem comes when I try to access the static method  
"mouseLocation", the attached code returns the following:

******
The event type is 1
The # of consecutive mouse click was 1
2007-03-12 10:10:27.285 mono[22248] *** -[NSEvent mouseLocation]:  
selector not recognized [self = 0x151501d0]
2007-03-12 10:10:27.285 mono[22248] *** -[NSEvent mouseLocation]:  
selector not recognized [self = 0x151501d0]
******

[Cocoa.Register ("OpenGlViewer")]
public class Viewer : Cocoa.OpenGLView
....
[Cocoa.Export ("mouseDown:")]
private void Viewer_MouseDown(Cocoa.Object eventArgs)
{
	int type = (int) Cocoa.ObjCMessaging.objc_msgSend  
(eventArgs.NativeObject, "type", typeof (int)); // works!!
	Console.WriteLine("The event type is " + type.ToString());
			
	int count = (int) Cocoa.ObjCMessaging.objc_msgSend  
(eventArgs.NativeObject, "clickCount", typeof (int)); // works!!
	Console.WriteLine("The # of consecutive mouse click was " +  
count.ToString());
	
	Cocoa.Point location = (Cocoa.Point)  
Cocoa.ObjCMessaging.objc_msgSend (eventArgs.NativeObject,  
"mouseLocation", typeof (Cocoa.Point)); // does NOT work!!
}

Any ideas?? How am I supposed to send a message to a static method?

Regards,

Pedro



More information about the Cocoa-sharp mailing list