Feat:右键多选节点结束时禁止触发节点右键菜单事件,避免触发右键菜单显示

This commit is contained in:
wanglin2
2023-08-29 09:46:36 +08:00
parent f7f234b4cb
commit a3362e44fe
2 changed files with 16 additions and 2 deletions

View File

@@ -449,13 +449,17 @@ class Node {
})
// 右键菜单事件
this.group.on('contextmenu', e => {
const { readonly, useLeftKeySelectionRightKeyDrag } = this.mindMap.opt
// 按住ctrl键点击鼠标左键不知为何触发的是contextmenu事件
if (this.mindMap.opt.readonly || e.ctrlKey) {
// || this.isGeneralization
if (readonly || e.ctrlKey) {
return
}
e.stopPropagation()
e.preventDefault()
// 如果是多选节点结束,那么不要触发右键菜单事件
if(!useLeftKeySelectionRightKeyDrag && this.mindMap.select.hasSelectRange()) {
return
}
if (this.nodeData.data.isActive) {
this.renderer.clearActive()
}

View File

@@ -11,6 +11,7 @@ class Select {
this.mouseDownY = 0
this.mouseMoveX = 0
this.mouseMoveY = 0
this.isSelecting = false
this.bindEvent()
}
@@ -70,11 +71,15 @@ class Select {
this.isMousedown = false
if (this.rect) this.rect.remove()
this.rect = null
setTimeout(() => {
this.isSelecting = false
}, 0)
})
}
// 鼠标移动事件
onMove(x, y) {
this.isSelecting = true
// 绘制矩形
this.rect.plot([
[this.mouseDownX, this.mouseDownY],
@@ -172,6 +177,11 @@ class Select {
}
})
}
// 是否存在选区
hasSelectRange() {
return this.isSelecting
}
}
Select.instanceName = 'select'