summaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-04-24 19:00:15 +0200
committerSven Gothel <[email protected]>2012-04-24 19:00:15 +0200
commit781865768bb8da38cf3de254b93bae0a8d43f1a6 (patch)
treec064c990228cb031f32948e997acd27e7c943c61 /src/newt
parent5854705968e73c222724be24eecd21c488a7e977 (diff)
Newt/AWT Event Factory: Add Mouse Wheel Event Conversion
.. also reverse AWT rotation sign, since NEWT uses the reverse oriantation.
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java15
-rw-r--r--src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java3
2 files changed, 16 insertions, 2 deletions
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java
index 5dcd4d962..115743a0d 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java
@@ -30,7 +30,9 @@ package com.jogamp.newt.event.awt;
import jogamp.newt.awt.event.AWTNewtEventFactory;
-public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener
+public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseListener,
+ java.awt.event.MouseMotionListener,
+ java.awt.event.MouseWheelListener
{
public AWTMouseAdapter(com.jogamp.newt.event.MouseListener newtListener) {
super(newtListener);
@@ -47,12 +49,14 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
public AWTAdapter addTo(java.awt.Component awtComponent) {
awtComponent.addMouseListener(this);
awtComponent.addMouseMotionListener(this);
+ awtComponent.addMouseWheelListener(this);
return this;
}
public AWTAdapter removeFrom(java.awt.Component awtComponent) {
awtComponent.removeMouseListener(this);
awtComponent.removeMouseMotionListener(this);
+ awtComponent.removeMouseWheelListener(this);
return this;
}
@@ -118,5 +122,14 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
enqueueEvent(false, event);
}
}
+
+ public void mouseWheelMoved(java.awt.event.MouseWheelEvent e) {
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.MouseListener)newtListener).mouseWheelMoved(event);
+ } else {
+ enqueueEvent(false, event);
+ }
+ }
}
diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
index d64cc9359..cb70da13f 100644
--- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
@@ -120,7 +120,8 @@ public class AWTNewtEventFactory {
if(0xFFFFFFFF != type) {
int rotation = 0;
if (event instanceof java.awt.event.MouseWheelEvent) {
- rotation = ((java.awt.event.MouseWheelEvent)event).getWheelRotation();
+ // AWT/NEWT rotation is reversed - AWT +1 is down, NEWT +1 is up.
+ rotation = -1 * ((java.awt.event.MouseWheelEvent)event).getWheelRotation();
}
int mods = awtModifiers2Newt(event.getModifiers(), true);