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

JavaFX mouse move events and mouse drag events don't work in Linux

    XMLWordPrintable

Details

    • x86_64
    • linux_debian_3.0

    Description

      ADDITIONAL SYSTEM INFORMATION :
      $ uname -a
      Linux neptune 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux
      $ java -version
      openjdk version "16.0.1" 2021-04-20
      OpenJDK Runtime Environment AdoptOpenJDK-16.0.1+9 (build 16.0.1+9)
      OpenJDK 64-Bit Server VM AdoptOpenJDK-16.0.1+9 (build 16.0.1+9, mixed mode, sharing)
      $ ls /opt/javafx-sdk-16
      legal lib


      A DESCRIPTION OF THE PROBLEM :
      In Linux, any JavaFX Node generates mouse moved events only for the following:

      * The first mouse entry
      * Any mouse exit
      * Any mouse press

      Mouse drag events are generated only for the mouse button release at the end of the drag.



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Set the onMouseMoved or onMouseDragged on any JavaFX Node in Linux, or add an event filter or event handler for mouse moved or mouse dragged events. Add that node to a Stage, run the program, and move or drag the mouse over the node.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Every mouse movement should trigger a mouse moved or mouse dragged handler.
      ACTUAL -
      A Node generates mouse moved events only for the following:

      * The first mouse entry
      * Any mouse exit
      * Any mouse press

      Mouse drag events are generated only for the mouse button release at the end of the drag.


      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.stage.Stage;
      import javafx.scene.Node;
      import javafx.scene.Scene;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.canvas.Canvas;

      public class MouseMoveTest
      extends Application {
          @Override
          public void start(Stage stage) {
              Node node = new Canvas(600, 600);
              node.setOnMouseClicked(e ->
                  System.out.printf("Click: %.1f, %.1f%n",
                      e.getScreenX(), e.getScreenY()));
              node.setOnMouseDragged(e ->
                  System.out.printf("Drag: %.1f, %.1f%n",
                      e.getScreenX(), e.getScreenY()));
              node.setOnMouseMoved(e ->
                  System.out.printf("Move: %.1f, %.1f%n",
                      e.getScreenX(), e.getScreenY()));

              BorderPane pane = new BorderPane(node);

              stage.setScene(new Scene(pane));
              stage.setTitle("Mouse Move Test");
              stage.show();
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      This problem does not occur in Java 8, so using Java 8 could be one workaround. The problem exists in Java FX 11. I was not able to find a place from which to download JavaFX 9 or 10, so I don't know if the problem exists in those versions.

      FREQUENCY : always


      Attachments

        Activity

          People

            pnarayanaswa Praveen Narayanaswamy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: