mouseup 修复无法及时更新

main
zcy 2024-03-09 18:13:36 +08:00
parent 1b08d6592e
commit 8eca70acce
1 changed files with 50 additions and 26 deletions

View File

@ -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,8 +79,57 @@ 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);
this.graph.setConnectableEdges(true);