diff options
author | Sven Gothel <[email protected]> | 2011-12-02 07:54:41 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-12-02 07:54:41 +0100 |
commit | 30c959a4534bc0c6b4718ae65fd4f91d68d6eca6 (patch) | |
tree | 09d676201680f6a670385c8e5f78d23b4eea9955 /src/newt/native/NewtMacWindow.m | |
parent | 4856f7800bac165c3770495b77de4a2eabcca46e (diff) |
NEWT EVENT_MOUSE_WHEEL_MOVED: Fix Bug 413 - Generate proper mouse wheel events.
> 0: UP
< 0: DOWN
See MouseEvent.getWheelRotation() for details.
OSX/Windows: Default to wheel 'button' 1
OSX: Properly report '<0'
X11: Synthesize wheel events by mapping buttons 4/5 and 6/7 to wheel 1 and 2.
Diffstat (limited to 'src/newt/native/NewtMacWindow.m')
-rw-r--r-- | src/newt/native/NewtMacWindow.m | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 1018633b1..ce41673c4 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -44,15 +44,17 @@ jint GetDeltaY(NSEvent *event, jint javaMods) { // mouse pad case deltaY = CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis1); + // fprintf(stderr, "WHEEL/PAD: %lf\n", (double)deltaY); } else { // traditional mouse wheel case deltaY = [event deltaY]; + // fprintf(stderr, "WHEEL/TRAD: %lf\n", (double)deltaY); if (deltaY == 0.0 && (javaMods & EVENT_SHIFT_MASK) != 0) { // shift+vertical wheel scroll produces horizontal scroll // we convert it to vertical deltaY = [event deltaX]; } - if (deltaY < 1.0 && deltaY > -1.0) { + if (-1.0 < deltaY && deltaY < 1.0) { deltaY *= 10.0; } else { if (deltaY < 0.0) { @@ -62,14 +64,8 @@ jint GetDeltaY(NSEvent *event, jint javaMods) { } } } - - if (deltaY > 0) { - return (NSInteger)deltaY; - } else if (deltaY < 0) { - return -(NSInteger)deltaY; - } - - return 0; + // fprintf(stderr, "WHEEL/res: %d\n", (int)deltaY); + return (jint) deltaY; } static jmethodID enqueueMouseEventID = NULL; @@ -581,6 +577,7 @@ static jint mods2JavaMods(NSUInteger mods) switch ([event type]) { case NSScrollWheel: { scrollDeltaY = GetDeltaY(event, javaMods); + javaButtonNum = 1; break; } case NSLeftMouseDown: @@ -598,9 +595,6 @@ static jint mods2JavaMods(NSUInteger mods) case NSOtherMouseDragged: javaButtonNum = 2; break; - default: - javaButtonNum = 0; - break; } if (evType == EVENT_MOUSE_WHEEL_MOVED && scrollDeltaY == 0) { |