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

When scene is embedded in SWT with FXCanvas, Mouse scrolling in popups (e.g. from ComboBox) closes the popup.

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_7

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_144"
      Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
      Java HotSpot(TM) Client VM (build 25.144-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      Using the scroll wheel on a popup (e.g. the ListView of a ComboBox) hides the popup instead of scrolling it, when the scene is inside an FXCanvas of an SWT application.

      The reason seems to be that the scroll event gets caught by the FXCanvas and forwarded to the embedded scene, where it is treated as if the scroll had happened on the node underneath the popup, instead of the scroll event being handled by the scene of the popup.

      Clicking on elements in the popup works as expected.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Using the example code below, click the ComboBox. Mouse over the list and use mouse wheel to scroll.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The list should scroll. If the mouse pointer is not above the list, it should either scroll as well or do nothing (i.e. remain visible).
      ACTUAL -
      The list disappears.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import org.eclipse.swt.SWT;
      import org.eclipse.swt.layout.FillLayout;
      import org.eclipse.swt.widgets.Display;
      import org.eclipse.swt.widgets.Shell;

      import javafx.embed.swt.FXCanvas;
      import javafx.scene.Scene;
      import javafx.scene.control.ComboBox;
      import javafx.scene.layout.VBox;

      public class ComboBoxInFXCanvasExample {

        public static void main(String[] args) {
          Display display = new Display();
          Shell shell = new Shell(display);
          shell.setLayout(new FillLayout());
          FXCanvas canvas = new FXCanvas(shell, SWT.NONE);
          Scene scene = createScene();
          canvas.setScene(scene);
          shell.open();
          while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
              display.sleep();
            }
          }
          display.dispose();
        }

        private static Scene createScene() {
          ComboBox<String> box = new ComboBox<>();
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");
          box.getItems().add("asd");

          VBox root = new VBox(box);
          return new Scene(root);
        }

      }
      ---------- END SOURCE ----------

        Attachments

        1. jdk9jars.zip
          2.45 MB
        2. jdk8jars.zip
          1.58 MB
        3. ComboBoxInFXCanvasExample.java
          2 kB

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: