Quellcode durchsuchen

FileTree: fix drag & drop in an empty scenetree

lviguier vor 1 Monat
Ursprung
Commit
5ea795ba19
2 geänderte Dateien mit 10 neuen und 2 gelöschten Zeilen
  1. 6 0
      hide/comp/FancyTree.hx
  2. 4 2
      hide/comp/SceneEditor.hx

+ 6 - 0
hide/comp/FancyTree.hx

@@ -356,6 +356,12 @@ class FancyTree<TreeItem> extends hide.comp.Component {
 		rootData = generateChildren(null);
 		recLoadChildren(rootData);
 
+		element.get(0).ondrop = (e: js.html.DragEvent) -> {
+			e.preventDefault();
+			e.stopPropagation();
+			dragAndDropInterface.onDrop(null, DropOperation.Inside, e);
+		}
+
 		queueRefresh(Search);
 	}
 

+ 4 - 2
hide/comp/SceneEditor.hx

@@ -2089,8 +2089,10 @@ class SceneEditor {
 				return Reorder;
 			},
 			onDrop: function(target: hrt.prefab.Prefab, operation: hide.comp.FancyTree.DropOperation, e: js.html.DragEvent) : Bool {
-				var parent = operation.match(hide.comp.FancyTree.DropOperation.Inside) ? target : target.parent;
-				var tChildren = target.parent.children;
+				if (target == null)
+					target = sceneData;
+				var parent = operation.match(hide.comp.FancyTree.DropOperation.Inside) ? target : target?.parent;
+				var tChildren = target.parent == null ? target.children : target.parent.children;
 
 				var prefabs : Array<hrt.prefab.Prefab> = cast ide.getData("drag/scenetree");
 				if (prefabs != null) {