changeset 5741:2650ad7e53bf

RT-34158: NPE when pressing both mouse keys in FXCanvas Summary: The fix was to stop check both the button and the event mask Reviewed-by: snorthov (owner)
author snorthov
date Mon, 18 Nov 2013 16:24:16 -0500
parents d892fc853b2a
children 6b44a535f706
files modules/swt/src/main/java/javafx/embed/swt/SWTEvents.java
diffstat 1 files changed, 5 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/modules/swt/src/main/java/javafx/embed/swt/SWTEvents.java	Tue Nov 19 07:59:52 2013 +1300
+++ b/modules/swt/src/main/java/javafx/embed/swt/SWTEvents.java	Mon Nov 18 16:24:16 2013 -0500
@@ -64,19 +64,13 @@
         return 0;
     }
 */
-    // NOTE: not tested (are masked needed?)
     static int mouseButtonToEmbedMouseButton(int button, int extModifiers) {
-        int embedMouseButton = AbstractEvents.MOUSEEVENT_NONE_BUTTON;
-        if ((button == 1) || (extModifiers & SWT.BUTTON1) != 0) {
-            embedMouseButton |= AbstractEvents.MOUSEEVENT_PRIMARY_BUTTON;
+        switch (button) {
+            case 1: return AbstractEvents.MOUSEEVENT_PRIMARY_BUTTON;
+            case 2: return AbstractEvents.MOUSEEVENT_MIDDLE_BUTTON;
+            case 3: return AbstractEvents.MOUSEEVENT_SECONDARY_BUTTON;
         }
-        if ((button == 2) || (extModifiers & SWT.BUTTON2) != 0) {
-            embedMouseButton |= AbstractEvents.MOUSEEVENT_MIDDLE_BUTTON;
-        }
-        if ((button == 3) || (extModifiers & SWT.BUTTON3) != 0) {
-            embedMouseButton |= AbstractEvents.MOUSEEVENT_SECONDARY_BUTTON;
-        }
-        return embedMouseButton;
+        return AbstractEvents.MOUSEEVENT_NONE_BUTTON;
     }
 
     static int getWheelRotation(MouseEvent e, int embedMouseType) {