[Enhancement] NBTTreeView 自动展开 (#5467)

This commit is contained in:
Calboot
2026-02-08 20:29:24 +08:00
committed by GitHub
parent 8d504cd194
commit dec2e4ec7a

View File

@@ -41,6 +41,7 @@ public final class NBTTreeView extends TreeView<Tag> {
public NBTTreeView(NBTTreeView.Item tree) { public NBTTreeView(NBTTreeView.Item tree) {
this.setRoot(tree); this.setRoot(tree);
if (tree != null) tree.setExpanded(true);
this.setCellFactory(cellFactory()); this.setCellFactory(cellFactory());
} }
@@ -141,6 +142,9 @@ public final class NBTTreeView extends TreeView<Tag> {
item.getChildren().add(subTree); item.getChildren().add(subTree);
} }
} }
FXUtils.onChangeAndOperate(item.expandedProperty(), expanded -> {
if (expanded && item.getChildren().size() == 1) item.getChildren().get(0).setExpanded(true);
});
return item; return item;
} }