changeset 7276:d10817fc3844

RT-37436: [FXCanvas, JFXPanel] NPE in Browser while pressing back/forward buttons from mouse Reviewed by: felipe, anthony
author snorthov
date Tue, 10 Jun 2014 14:06:11 -0400
parents 30b24988ef50
children 79ce29689619
files modules/swing/src/main/java/javafx/embed/swing/JFXPanel.java modules/swt/src/main/java/javafx/embed/swt/FXCanvas.java
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/modules/swing/src/main/java/javafx/embed/swing/JFXPanel.java	Tue Jun 10 21:17:19 2014 +0400
+++ b/modules/swing/src/main/java/javafx/embed/swing/JFXPanel.java	Tue Jun 10 14:06:11 2014 -0400
@@ -319,6 +319,15 @@
         if (scenePeer == null || !isFxEnabled()) {
             return;
         }
+        
+        // FX only supports 3 buttons so don't send the event for other buttons
+        switch (e.getID()) {
+            case MouseEvent.MOUSE_DRAGGED:
+            case MouseEvent.MOUSE_PRESSED:
+            case MouseEvent.MOUSE_RELEASED:
+                if (e.getButton() > 3)  return;
+                break;
+        }
 
         int extModifiers = e.getModifiersEx();
         // Fix for RT-15457: we should report no mouse button upon mouse release, so
--- a/modules/swt/src/main/java/javafx/embed/swt/FXCanvas.java	Tue Jun 10 21:17:19 2014 +0400
+++ b/modules/swt/src/main/java/javafx/embed/swt/FXCanvas.java	Tue Jun 10 14:06:11 2014 -0400
@@ -398,17 +398,26 @@
             }
             @Override
             public void mouseDown(MouseEvent me) {
+                // FX only supports 3 buttons so don't send the event for other buttons
+                if (me.button > 3) return;
                 FXCanvas.this.sendMouseEventToFX(me, AbstractEvents.MOUSEEVENT_PRESSED);
             }
             @Override
             public void mouseUp(MouseEvent me) {
+                // FX only supports 3 buttons so don't send the event for other buttons
+                if (me.button > 3) return;
                 FXCanvas.this.sendMouseEventToFX(me, AbstractEvents.MOUSEEVENT_RELEASED);
             }
         });
 
         addMouseMoveListener(me -> {
             if ((me.stateMask & SWT.BUTTON_MASK) != 0) {
-                FXCanvas.this.sendMouseEventToFX(me, AbstractEvents.MOUSEEVENT_DRAGGED);
+                // FX only supports 3 buttons so don't send the event for other buttons
+                if ((me.stateMask & (SWT.BUTTON1 | SWT.BUTTON2 | SWT.BUTTON3)) != 0) {
+                    FXCanvas.this.sendMouseEventToFX(me, AbstractEvents.MOUSEEVENT_DRAGGED);
+                } else {
+                    FXCanvas.this.sendMouseEventToFX(me, AbstractEvents.MOUSEEVENT_MOVED);
+                }
             } else {
                 FXCanvas.this.sendMouseEventToFX(me, AbstractEvents.MOUSEEVENT_MOVED);
             }