How to disable deselection of nodes

Hi we have a diagram with maxSelectionCount is set to 1 and one node is selected on load. If the user clicks on the background, the selection goes off (deselected). is there anyway to restrict this? means, user can select an another node but cannot deselect( there should be always one node selected ).

I have seen DiagramEvents where i can find the previously selected node and select it again. But is there any way directly preventing deselection?

One cannot prevent users from clicking where they want. However one can control the effects of doing so.

I think you want to override the Tool.standardMouseSelect behavior. Something like:

  $(go.Diagram, "myDiagramDiv",
    {
      . . .,
      "clickSelectingTool.standardMouseSelect": function() {
          var diagram = this.diagram;
          if (diagram.findPartAt(diagram.lastInput.documentPoint,
false) === null) return;
          go.Tool.prototype.standardMouseSelect.call(this);
       },
     . . .
  })