Browse Source

fix inspector

ncannasse 6 years ago
parent
commit
2bddd11836
3 changed files with 10 additions and 4 deletions
  1. 6 2
      hxd/inspect/Inspector.hx
  2. 3 1
      hxd/inspect/Node.hx
  3. 1 1
      hxd/inspect/Panel.hx

+ 6 - 2
hxd/inspect/Inspector.hx

@@ -36,7 +36,7 @@ class Tool {
 class Inspector {
 
 	static var CSS = hxd.res.Embed.getFileContent("hxd/inspect/inspect.css");
-	static var current : Inspector;
+	static var current(default,set) : Inspector;
 
 	public static function getCurrent() return current;
 
@@ -82,7 +82,10 @@ class Inspector {
 		init();
 	}
 
-
+	static function set_current(i:Inspector) {
+		@:privateAccess Node.currentJRoot = i == null ? null : i.jroot;
+		return current = i;
+	}
 
 	function init() {
 		jroot = J(props.getRoot());
@@ -92,6 +95,7 @@ class Inspector {
 			</ul>
 		');
 		jroot.attr("title", "Inspect");
+		current = this;
 
 		scenePanel = new ScenePanel("s3d", scene);
 		logPanel = new Panel("log", "Log");

+ 3 - 1
hxd/inspect/Node.hx

@@ -8,6 +8,8 @@ class Node {
 	public var j : vdom.JQuery;
 	var childs : Array<Node>;
 
+	static var currentJRoot : vdom.JQuery = null;
+
 	public function new( name, ?parent ) {
 		childs = [];
 		initContent();
@@ -20,7 +22,7 @@ class Node {
 	}
 
 	function getJRoot() : vdom.JQuery {
-		return null;
+		return currentJRoot;
 	}
 
 	function initContent() {

+ 1 - 1
hxd/inspect/Panel.hx

@@ -69,7 +69,7 @@ class Panel extends Node {
 	}
 
 	override function getJRoot() {
-		if( j == null ) return @:privateAccess inspect.jroot;
+		if( j == null ) return super.getJRoot();
 		return j;
 	}