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

[Button] default and cancel accelerator removing is implemented incorrectly in behavior set to false

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • 8
    • javafx
    • 8.0b86

      I was observing code of listener removing :

          private void setDefaultButton(boolean value) {

              KeyCode acceleratorCode = KeyCode.ENTER;
              defaultAcceleratorKeyCodeCombination =
                      new KeyCodeCombination(acceleratorCode);

              if (! value) {
                  Runnable oldDefault = getSkinnable().getParent().getScene().getAccelerators().get(defaultAcceleratorKeyCodeCombination);
                  if (!defaultButtonRunnable.equals(oldDefault)) { getSkinnable().getParent().getScene().getAccelerators().remove(defaultAcceleratorKeyCodeCombination);
                  }
              }
              getSkinnable().getParent().getScene().getAccelerators().put(defaultAcceleratorKeyCodeCombination, defaultButtonRunnable);
          }

      suppose, we call it with false:

      setDefaultButton(false);

      if (!false) -> true

      we get oldDefault. if the current button is oldDefault then false, and we don't remove.

      So, I cannot remove default button dehavior. The same for cancel behavior.

      To reproduce, run the attached application.
      The default button is button.
      Click enter in text field. Default button fires and becomes not default. Press again, and it is fired again.

            miflemi Mick Fleming
            akirov Alexander Kirov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: