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

FXCanvas should properly forward consumption state of key events from SWT to embedded scene

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      other

      Description

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      org.eclipse.swt.events.KeyEvent provides a boolean doit flag, which can be set to false to indicate the event should be ignored by key handlers.

       /**
        * A flag indicating whether the operation should be allowed.
        * Setting this field to <code>false</code> will cancel the operation.
        */
      public boolean doit;

      In the context of FXCanvas this information is lost, as its not transferred to the embedded scene. As its functionality corresponds to that of javafx.event.Event.consumed the value could be transferred accordingly within FXCanvas.sendKeyEventToFX(KeyEvent, int).


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package canvas.bug;

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

      import javafx.embed.swt.FXCanvas;
      import javafx.event.EventHandler;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.input.KeyEvent;

      public class FXCanvasTests {

      @Test
      public void eventConsumption() {
      Display display = new Display();
      Shell shell = new Shell(display);
      shell.setLayout(new FillLayout());
      FXCanvas canvas = new FXCanvas(shell, SWT.NONE);

      Scene scene = new Scene(new Group(), 400, 400);
      canvas.setScene(scene);
      scene.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
      public void handle(final KeyEvent keyEvent) {
      System.out.println("Handler: " + keyEvent);
      }
      });
      scene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
      public void handle(final KeyEvent keyEvent) {
      System.out.println("Filter: " + keyEvent);
      }
      });

      shell.setSize((int) scene.getWidth(), (int) scene.getHeight());
      shell.open();

      canvas.setFocus();
      org.eclipse.swt.widgets.Event event = new org.eclipse.swt.widgets.Event();
      event.widget = canvas;
      event.type = SWT.KeyDown;
      event.keyCode = SWT.DEL;
      event.doit = false;
      canvas.notifyListeners(SWT.KeyDown, event);

      while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
      display.sleep();
      }
      }
      display.dispose();
      }
      }
      ---------- END SOURCE ----------

        Activity

        webbuggrp Webbug Group created issue -
        aroy Abhijit Roy made changes -
        Field Original Value New Value
        Labels webbug dcsroy reproducer-yes webbug
        aroy Abhijit Roy made changes -
        Attachment FXCanvasTests.java [ 60258 ]
        aroy Abhijit Roy made changes -
        Project Java Incidents [ 10301 ] JDK [ 10100 ]
        Key JI-9039178 JDK-8159227
        Workflow JBS Incident Workflow [ 4896076 ] JBS Workflow [ 4896076 ]
        Component/s javafx [ 11900 ]
        Component/s javafx [ 11901 ]
        Affects Version/s 8u92 [ 18505 ]
        Affects Version/s 8u92 [ 18546 ]
        aroy Abhijit Roy made changes -
        Subcomponent other [ 1402 ] other [ 1385 ]
        vdyakov Victor Dyakov made changes -
        Assignee Kevin Rushforth [ kcr ]
        kcr Kevin Rushforth made changes -
        Summary FXCanvas should properly forward consumption state of key events from SWT to embedded scene. FXCanvas should properly forward consumption state of key events from SWT to embedded scene
        kcr Kevin Rushforth made changes -
        Fix Version/s 9 [ 14949 ]
        kcr Kevin Rushforth made changes -
        Affects Version/s 9 [ 14949 ]
        kcr Kevin Rushforth made changes -
        Status New [ 10000 ] Open [ 1 ]
        kcr Kevin Rushforth made changes -
        Labels dcsroy reproducer-yes webbug dcsroy nicetohave reproducer-yes webbug
        kcr Kevin Rushforth made changes -
        Fix Version/s tbd_major [ 11972 ]
        Fix Version/s 9 [ 14949 ]
        kcr Kevin Rushforth made changes -
        Fix Version/s 10 [ 16302 ]
        Fix Version/s tbd_major [ 11972 ]
        asaha Abhijit Saha made changes -
        Fix Version/s tbd_major [ 11972 ]
        Fix Version/s 10 [ 16302 ]
        asaha Abhijit Saha made changes -
        Assignee Kevin Rushforth [ kcr ]

          People

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

            Dates

            • Created:
              Updated: