Merge pull request #4797 from JakubValtar/fix-mouse-button-events

Unify mouse pressed/released events across renderers
This commit is contained in:
Ben Fry
2017-01-06 10:56:09 -05:00
committed by GitHub
2 changed files with 20 additions and 17 deletions
+10 -11
View File
@@ -848,11 +848,6 @@ public class PSurfaceFX implements PSurface {
int count = fxEvent.getClickCount();
int action = mouseMap.get(fxEvent.getEventType());
//EventType<? extends MouseEvent> et = nativeEvent.getEventType();
// if (et == MouseEvent.MOUSE_PRESSED) {
// peAction = processing.event.MouseEvent.PRESS;
// } else if (et == MouseEvent.MOUSE_RELEASED) {
// peAction = processing.event.MouseEvent.RELEASE;
int modifiers = 0;
if (fxEvent.isShiftDown()) {
@@ -869,12 +864,16 @@ public class PSurfaceFX implements PSurface {
}
int button = 0;
if (fxEvent.isPrimaryButtonDown()) {
button = PConstants.LEFT;
} else if (fxEvent.isSecondaryButtonDown()) {
button = PConstants.RIGHT;
} else if (fxEvent.isMiddleButtonDown()) {
button = PConstants.CENTER;
switch (fxEvent.getButton()) {
case PRIMARY:
button = PConstants.LEFT;
break;
case SECONDARY:
button = PConstants.RIGHT;
break;
case MIDDLE:
button = PConstants.CENTER;
break;
}
// If running on Mac OS, allow ctrl-click as right mouse.
+10 -6
View File
@@ -1060,12 +1060,16 @@ public class PSurfaceJOGL implements PSurface {
InputEvent.ALT_MASK);
int peButton = 0;
if ((modifiers & InputEvent.BUTTON1_MASK) != 0) {
peButton = PConstants.LEFT;
} else if ((modifiers & InputEvent.BUTTON2_MASK) != 0) {
peButton = PConstants.CENTER;
} else if ((modifiers & InputEvent.BUTTON3_MASK) != 0) {
peButton = PConstants.RIGHT;
switch (nativeEvent.getButton()) {
case com.jogamp.newt.event.MouseEvent.BUTTON1:
peButton = PConstants.LEFT;
break;
case com.jogamp.newt.event.MouseEvent.BUTTON2:
peButton = PConstants.CENTER;
break;
case com.jogamp.newt.event.MouseEvent.BUTTON3:
peButton = PConstants.RIGHT;
break;
}
if (PApplet.platform == PConstants.MACOSX) {