JDK-8088262 : [SWT] FXCanvas swallows almost all gesture events
  • Type: Bug
  • Component: javafx
  • Sub-Component: swing
  • Affected Version: 7u25,7u40
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2013-10-09
  • Updated: 2018-09-06
  • Resolved: 2016-09-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
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.
Comments
This issue has been broken down into JDK-8143596 (no forwarding of gesture events) and JDK-8161282 (no forwarding of horizontal mouse scroll events).
08-09-2016

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.
11-10-2013

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.
10-10-2013

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?
10-10-2013

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(); } } }
09-10-2013