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

[SWT] FXCanvas swallows almost all gesture events

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 7u25, 7u40
    • Fix Version/s: tbd_major
    • Component/s: javafx
    • Labels:
    • Environment:

      MacOSX 10.7, SWT from Eclipse Kepler SR1 (4.3.1), JDK 1.7.0.25 and JDK 1.8.0ea

      Description

      When embedded in an FXCanvas, my JavaFX scene doesn't receive any but vertical scroll events (with a very coarse resolution of multiples of 40). All other gesture events are swallowed.

        Issue Links

          Activity

          Hide
          jkoehnleijfx Jan Koehnlein (Inactive) added a comment -
          No SwipeEvents and RotateEvents passes through.

          Example file test/Test.java: When run, only horizontal scroll events are reported.

          package test;

          import javafx.embed.swt.FXCanvas;
          import javafx.event.EventHandler;
          import javafx.scene.Group;
          import javafx.scene.Scene;
          import javafx.scene.control.Button;
          import javafx.scene.input.ScrollEvent;

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

          public class Test {
          private static Scene createScene() {
          Group group = new Group();
          Scene scene = new Scene(group);
          Button button = new Button("JFX Button");
          button.setOnScroll(new EventHandler<ScrollEvent>() {
          @Override
          public void handle(ScrollEvent event) {
          System.out.println("scroll " + event.getDeltaX() + ":"
          + event.getDeltaY());
          }
          });
          group.getChildren().add(button);
          return scene;
          }

          public static void main(String[] args) {
          try {
          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();
          } catch (Exception e) {
          e.printStackTrace();
          }
          }
          }
          Show
          jkoehnleijfx Jan Koehnlein (Inactive) added a comment - No SwipeEvents and RotateEvents passes through. Example file test/Test.java: When run, only horizontal scroll events are reported. package test; import javafx.embed.swt.FXCanvas; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.input.ScrollEvent; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class Test { private static Scene createScene() { Group group = new Group(); Scene scene = new Scene(group); Button button = new Button("JFX Button"); button.setOnScroll(new EventHandler<ScrollEvent>() { @Override public void handle(ScrollEvent event) { System.out.println("scroll " + event.getDeltaX() + ":" + event.getDeltaY()); } }); group.getChildren().add(button); return scene; } public static void main(String[] args) { try { 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(); } catch (Exception e) { e.printStackTrace(); } } }
          Hide
          jkoehnleijfx Jan Koehnlein (Inactive) added a comment -
          Looking at the source code of FXCanvas, the transfer of GestureEvents seems not to be implemented. There is a sendWhatsoeverEventToFX method for everything but GestureEvents. Am I right that this is the place where it should be added?
          Show
          jkoehnleijfx Jan Koehnlein (Inactive) added a comment - Looking at the source code of FXCanvas, the transfer of GestureEvents seems not to be implemented. There is a sendWhatsoeverEventToFX method for everything but GestureEvents. Am I right that this is the place where it should be added?
          Hide
          snorthov Steve Northover (Inactive) added a comment -
          Yes. FX interop is lightweight. The embedding toolkit (SWT or AWT/Swing) sends events to FX and FX sends back images that the embedding toolkit draws. Gesture events would need to be handled the same way.
          Show
          snorthov Steve Northover (Inactive) added a comment - Yes. FX interop is lightweight. The embedding toolkit (SWT or AWT/Swing) sends events to FX and FX sends back images that the embedding toolkit draws. Gesture events would need to be handled the same way.
          Hide
          jkoehnleijfx Jan Koehnlein (Inactive) added a comment -
          Just implemented that for myself. You can find the code at https://github.com/JanKoehnlein/JavaFX-SWT-Gesture-Bridge. It's kind of a hack, as I have to access two private fields in order to hook into JavaFX, but it contains all the logic necessary to convert and transfer the gesture events.

          Unfortunately, it's not a patch, as I currently don't have the time to setup a working JavaFX development environment. But feel free to reuse the code / idea. If licensing is a problem (currently EPL) I can change it to whatever you want.
          Show
          jkoehnleijfx Jan Koehnlein (Inactive) added a comment - Just implemented that for myself. You can find the code at https://github.com/JanKoehnlein/JavaFX-SWT-Gesture-Bridge . It's kind of a hack, as I have to access two private fields in order to hook into JavaFX, but it contains all the logic necessary to convert and transfer the gesture events. Unfortunately, it's not a patch, as I currently don't have the time to setup a working JavaFX development environment. But feel free to reuse the code / idea. If licensing is a problem (currently EPL) I can change it to whatever you want.
          Hide
          anyssen Alexander Nyssen added a comment -
          This issue has been broken down into JDK-8143596 (no forwarding of gesture events) and JDK-8161282 (no forwarding of horizontal mouse scroll events).
          Show
          anyssen Alexander Nyssen added a comment - This issue has been broken down into JDK-8143596 (no forwarding of gesture events) and JDK-8161282 (no forwarding of horizontal mouse scroll events).

            People

            • Assignee:
              azvegint Alexander Zvegintsev (Inactive)
              Reporter:
              jkoehnleijfx Jan Koehnlein (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: