Inspector's hidden


When I don’t select any Node, I want the inspector has been hidden or removed , instead of the parameterized inspector as shown in the figure.What should I do?

Implement a “ChangedSelection” DiagramEvent listener and see if there is any Part selected that you care about.

Any examples?
How to code: if the mouse does not select any node and link, then hide inspector.

There are a handful of examples of using a ChangedSelection handler. Search · ChangedSelection · GitHub. You just need to get myDiagram.selection.first() and if it’s null, set the inspector to visible: false.

result:

code:

var inspector = new Inspector('myInspectorDiv', myDiagram,
  {
    properties: {
      "text": {},
      "key": { readOnly: true, show: Inspector.showIfPresent },
      "color": { show: Inspector.showIfPresent, type: 'color' },
      "Comments": { show: Inspector.showIfNode  },
      "flag": { show: Inspector.showIfNode, type: 'boolean', defaultValue: true  },
      "LinkComments": { show: Inspector.showIfLink },
    }
  });
myDiagram.addDiagramListener("ChangedSelection", function(diagramEvent) {
  var hh = myDiagram.selection.first();
  if (hh == null) {
    inspector.visible=false;
  }
});

When I don’t select any Node,the inspector has not been hidden or removed .

There is no “visible” property on the Inspector object.

Set the “display” style atttribute on the Inspector’s HTML DIV Element.