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

[Focus] if traverse focus in focus change listener, scene will have two focused controls

XMLWordPrintable

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

      Run the code:

          @Override
          public void start(Stage stage) throws Exception {
              final TextField tf1 = new TextField("text1"), tf2 = new TextField("text2");
              tf1.focusedProperty().addListener(new ChangeListener<Boolean>() {
                  @Override
                  public void changed(ObservableValue<? extends Boolean> ov, Boolean lostFocus, Boolean getFocus) {
                      if (lostFocus) {
                          tf1.requestFocus();
                      }
                  }
              });
              stage.setScene(new Scene(new VBox(tf1, tf2), 300, 300));
              stage.show();
          }

      Initially, text field 1 has a focus. Press TAB. Both textFields will be focused (visually), but only the first one will receive input, press tab again, and the second control will start to receive keyboard input, but they both will still be visually focused.

      Test case is from : http://stackoverflow.com/questions/14841622/javafx-after-dialog-two-textfields-gains-focus-instead-one

      Situation can be observed here : http://www.fotos-hochladen.net/view/focus2cd7ioyvr3g.png

            psafrata Pavel Ĺ afrata
            akirov Alexander Kirov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: