Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8194727

Jump in mouse event's y values when entering or exiting a node

XMLWordPrintable

    • generic
    • generic

      FULL PRODUCT VERSION :
      java version "1.8.0_152"
      Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
      Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.16299.125]

      A DESCRIPTION OF THE PROBLEM :
      When handling drag mouse events, moving into or out of a node causes the y values reported by the event with getY() to jump radically.

      This is possibly a duplicate of https://bugs.openjdk.java.net/browse/JDK-8190400, but could be an addition to it.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      The attached code creates a SubScene with a Box inside. Dragging the mouse from outside the box's area into the box's area or the opposite will cause the e.getY() values to jump, while e.getX() values remain correct.




      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      y values reported by getY() should be continuous.
      ACTUAL -
      y values reported by getY() jump.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Group;
      import javafx.scene.PerspectiveCamera;
      import javafx.scene.Scene;
      import javafx.scene.SceneAntialiasing;
      import javafx.scene.SubScene;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Box;
      import javafx.scene.transform.Rotate;
      import javafx.stage.Stage;

      public class YTest extends Application {

          private double zAngle = 90; // anything except for 0 or 180

          private final int width = 400, height = 400;

          @Override
          public void start(Stage stage) {
              Box box = new Box(100, 100, 100);
      // box.setMouseTransparent(true);
              SubScene subScene = new SubScene(new Group(box), width, height, true, SceneAntialiasing.BALANCED);

              PerspectiveCamera camera = new PerspectiveCamera(true);
              camera.getTransforms().addAll(new Rotate(zAngle));
              camera.setTranslateZ(-1000);
              camera.setFarClip(2000);
              subScene.setCamera(camera);

              subScene.setOnMouseDragged(e -> System.out.println(e.getX() + ", " + e.getY()));
              subScene.setFill(Color.RED);

              Scene scene = new Scene(new Group(subScene), width, height);
              stage.setScene(scene);
              stage.show();
          }

          public static void main(String[] args) {
              launch(args);
          }
      }


      The same issue exists with a 2D shape as well:

      Rectangle box = new Rectangle(100, 100);
      SubScene subScene = new SubScene(new Group(box), width, height);
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      This stops happening if box.setMouseTransparent(true) is called, or if zAngle is 0 or 180. None of those should be required.

            arapte Ambarish Rapte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: