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

[FXCanvas] ContextMenuEvent.isKeyboardTrigger always returns false

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u25
    • javafx

      The method isKeyboardTrigger of the class ContextMenuEvent returns false also for keyboard triggered context menus.

      import javafx.embed.swt.FXCanvas;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      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 TwoButtons {

        public static void main(String[] args) {
          final Display display = new Display();
          final Shell shell = new Shell(display);
          shell.setLayout(new FillLayout(SWT.VERTICAL));

          final FXCanvas fxCanvas = new FXCanvas(shell, SWT.NONE);
          Button button = new Button("Right click or press menu key!");
          Scene scene = new Scene(button);
          fxCanvas.setScene(scene);

          button.setOnContextMenuRequested(event ->
              button.setText("trigger is: " + (event.isKeyboardTrigger() ? "keyboard" : "mouse")));

          shell.open();
          while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
              display.sleep();
            }
          }
          display.dispose();
        }
      }

            Unassigned Unassigned
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Imported: