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

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

    Details

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

      8.0b86

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              • Due:
                Created:
                Updated:
                Resolved:
                Imported: