diff --git a/altium_sch_renderer.js b/altium_sch_renderer.js index d74e3ff..19470ae 100644 --- a/altium_sch_renderer.js +++ b/altium_sch_renderer.js @@ -61,31 +61,6 @@ class AltiumSchematicRenderer } render() { - let oldMove = mxGraphHandler.prototype.mouseMove - mxGraphHandler.prototype.mouseMove = function(sender, me){ - // console.log("mouse move",sender,me) - // https://github.com/jgraph/mxgraph/blob/master/javascript/src/js/handler/mxGraphHandler.js#L901 - if (!this.livePreviewUsed && this.shape == null) { - this.shape = this.createPreviewShape(this.bounds); - }else if(this.shape != null){ - // console.log("mouseMove",this) - } - oldMove.call(this, sender, me); - } - let oldClick = mxGraphHandler.prototype.mouseDown - mxGraphHandler.prototype.mouseDown = function(sender, me){ - console.log("mouse down",sender,me) - // https://github.com/jgraph/mxgraph/blob/master/javascript/src/js/handler/mxGraphHandler.js#L901 - if(me.state != undefined){ - if(me.state.cell.children != undefined){ - oldClick.call(this, sender, me); - - }else{ - // oldClick.call(this, sender, me); - } - } - - } // https://github.com/jgraph/mxgraph/blob/master/javascript/src/js/handler/mxGraphHandler.js#L1036 mxGraphHandler.prototype.updatePreview = function(remote) { @@ -104,7 +79,56 @@ class AltiumSchematicRenderer this.graph = new mxGraph(document.getElementById('graphContainer')); - + let oldMove = mxGraphHandler.prototype.mouseMove + mxGraphHandler.prototype.mouseMove = function(sender, me){ + console.log("mouse move",sender,me) + // https://github.com/jgraph/mxgraph/blob/master/javascript/src/js/handler/mxGraphHandler.js#L901 + if (!this.livePreviewUsed && this.shape == null) { + this.shape = this.createPreviewShape(this.bounds); + }else if(this.shape != null){ + console.log("mouseMove",this) + } + oldMove.call(this, sender, me); + } + + + let oldClick = mxGraphHandler.prototype.mouseDown + mxGraphHandler.prototype.mouseDown = function(sender, me){ + console.log("mouse down",sender,me) + // https://github.com/jgraph/mxgraph/blob/master/javascript/src/js/handler/mxGraphHandler.js#L901 + if(me.state != undefined){ + if(me.state.cell.children != undefined){ + oldClick.call(this, sender, me); + }else{ + console.log(me.state.cell) + if(me.state.cell.parent != undefined){ + this.graph.addSelectionCell(me.state.cell.parent) + oldClick.call(this, sender, me); + } + // oldClick.call(this, sender, me); + } + } + + } + + let oldMouseUp = mxGraphHandler.prototype.mouseUp + mxGraphHandler.prototype.mouseUp = function(sender, me){ + console.log("mouse up",sender,me) + // https://github.com/jgraph/mxgraph/blob/master/javascript/src/js/handler/mxGraphHandler.js#L901 + if(me.state != undefined){ + if(me.state.cell.children != undefined){ + oldMouseUp.call(this, sender, me); + }else{ + if(me.state.cell.parent != undefined){ + this.graph.addSelectionCell(me.state.cell.parent) + oldMouseUp.call(this, sender, me); + } + // oldClick.call(this, sender, me); + } + } + oldMouseUp.call(this, sender, me); + + } this.graph.setPanning(true); this.graph.setConnectable(true);