[TreeView] Focus doesn't follow the selection after adding children.

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 8u20
    • Affects Version/s: 8u20
    • Component/s: javafx
    • None

      Start HelloTreeView.
      Select "Child Node 4".
      Press "Add child To Child Node 2" button.
      Press triangle to open "Child Node 2"
      Note that the selection remains on Child Node 4, but focus moves to Child Node 5.
      Adding this code at the end of buildSimpleTab method
              treeView.getFocusModel().focusedIndexProperty().addListener((observable, oldValue, newValue) -> {
                  System.out.println("focusedIndex: " + oldValue + " to " + newValue);
              });
      reveals this log:
      SelectedIndex: 4
      focusedIndex: -1 to 4
      SelectedIndices: [4], removed: [], addedFrom: 0, addedTo: 1
      focusedIndex: 4 to 5 // after button press
      SelectedIndex: 5 // after triangle press
      SelectedIndices: [5], removed: [], addedFrom: 0, addedTo: 1
      focusedIndex: 5 to 6

            Assignee:
            Jonathan Giles
            Reporter:
            Vadim Pakhnushev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: