From 6aaddcca9dcefd240eb616e58ecffc1371d8f19b Mon Sep 17 00:00:00 2001 From: Christopher Campbell Date: Tue, 26 May 2009 18:52:23 +0000 Subject: Fixed NEWT mouse events on Mac OS X to be consistent with Windows implementation (0==none, 1==left, 2==middle, 3==right). git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1915 232f8b59-042b-4e1e-8c03-345bb8c30851 --- src/newt/native/NewtMacWindow.m | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/newt/native') diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index e97d8b9ca..75d0a8e62 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -157,6 +157,29 @@ static jint mods2JavaMods(NSUInteger mods) NSPoint location = NSMakePoint(curLocation.x - frameRect.origin.x, curLocation.y - frameRect.origin.y); + // convert to 1-based button number (or use zero if no button is involved) + jint javaButtonNum; + switch ([event type]) { + case NSLeftMouseDown: + case NSLeftMouseUp: + case NSLeftMouseDragged: + javaButtonNum = 1; + break; + case NSRightMouseDown: + case NSRightMouseUp: + case NSRightMouseDragged: + javaButtonNum = 3; + break; + case NSOtherMouseDown: + case NSOtherMouseUp: + case NSOtherMouseDragged: + javaButtonNum = 2; + break; + default: + javaButtonNum = 0; + break; + } + if (env == NULL) { return; } @@ -165,12 +188,11 @@ static jint mods2JavaMods(NSUInteger mods) return; } - // 1-base the button number (*env)->CallVoidMethod(env, javaWindowObject, sendMouseEventID, evType, javaMods, (jint) location.x, (jint) (contentRect.size.height - location.y), - (jint) (1 + [event buttonNumber]), 0); + javaButtonNum, 0); } - (void) mouseEntered: (NSEvent*) theEvent -- cgit v1.2.3