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

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 8
    • Affects Version/s: 8
    • Component/s: javafx
    • Environment:

      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.

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

              Created:
              Updated:
              Resolved:
              Imported: