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

KeyCodeCombinationBuilder doesn't work as expected

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 8
    • javafx
    • 8.0-graphics-scrum-b621-x64

      The following sequence

      KeyCodeCombinationBuilder.create().control(KeyCombination.ModifierValue.DOWN).code(KeyCode.DELETE).build();

      throws the following exception:

      java.lang.NullPointerException: Modifier value must not be null!
      at javafx.scene.input.KeyCombination.<init>(KeyCombination.java:176)
      at javafx.scene.input.KeyCodeCombination.<init>(KeyCodeCombination.java:65)
      at javafx.scene.input.KeyCodeCombinationBuilder.build(KeyCodeCombinationBuilder.java:100)
      at Bug2.start(Bug2.java:15)
      at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:491)
      at com.sun.javafx.application.PlatformImpl$6.run(PlatformImpl.java:251)
      at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:217)
      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.access$300(Unknown Source)
      at com.sun.glass.ui.win.WinApplication$3$1.run(Unknown Source)
      ... 1 more

      A workaround is to either set all modifiers explicitly which doesn't seem to be convenient:

              KeyCodeCombinationBuilder.create()
                      .alt(KeyCombination.ModifierValue.UP)
                      .meta(KeyCombination.ModifierValue.UP)
                      .shift(KeyCombination.ModifierValue.UP)
                      .shortcut(KeyCombination.ModifierValue.UP)
                      .control(KeyCombination.ModifierValue.DOWN)
                      .code(KeyCode.DELETE)
                      .build();

      or do not use builder at all:

      new KeyCodeCombination(KeyCode.INSERT, KeyCombination.CONTROL_DOWN)

            ekrejcir Eva Krejčířová (Inactive)
            mrkam Alexander Kuznetcov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: