mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-13 06:57:28 +08:00
Node selection fix
This commit is contained in:
@@ -30,6 +30,7 @@ export default class IMouseClickDrag extends IPointing {
|
||||
started = false
|
||||
|
||||
constructor(target, blueprint, options) {
|
||||
options.unlistenOnTextEdit
|
||||
super(target, blueprint, options)
|
||||
this.clickButton = options?.clickButton ?? 0
|
||||
this.exitAnyButton = options?.exitAnyButton ?? true
|
||||
@@ -114,12 +115,20 @@ export default class IMouseClickDrag extends IPointing {
|
||||
}
|
||||
}
|
||||
|
||||
this.listenEvents()
|
||||
}
|
||||
|
||||
listenEvents() {
|
||||
this.target.addEventListener("mousedown", this.#mouseDownHandler)
|
||||
if (this.clickButton == 2) {
|
||||
this.target.addEventListener("contextmenu", e => e.preventDefault())
|
||||
}
|
||||
}
|
||||
|
||||
unlistenEvents() {
|
||||
this.target.removeEventListener("mousedown", this.#mouseDownHandler)
|
||||
}
|
||||
|
||||
getEvent(eventName) {
|
||||
return new CustomEvent(eventName, {
|
||||
detail: {
|
||||
@@ -130,14 +139,6 @@ export default class IMouseClickDrag extends IPointing {
|
||||
})
|
||||
}
|
||||
|
||||
unlistenDOMElement() {
|
||||
super.unlistenDOMElement()
|
||||
this.target.removeEventListener("mousedown", this.#mouseDownHandler)
|
||||
if (this.clickButton == 2) {
|
||||
//this.target.removeEventListener("contextmenu", e => e.preventDefault())
|
||||
}
|
||||
}
|
||||
|
||||
/* Subclasses will override the following methods */
|
||||
clicked(location) {
|
||||
}
|
||||
|
||||
@@ -22,6 +22,11 @@ export default class MouseMoveNodes extends IMouseClickDrag {
|
||||
startDrag() {
|
||||
// Get the current mouse position
|
||||
this.mouseLocation = Utility.snapToGrid(this.clickedPosition, this.stepSize)
|
||||
|
||||
if (!this.target.selected) {
|
||||
this.blueprint.unselectAll()
|
||||
this.target.setSelected(true)
|
||||
}
|
||||
}
|
||||
|
||||
dragTo(location, movement) {
|
||||
@@ -46,4 +51,11 @@ export default class MouseMoveNodes extends IMouseClickDrag {
|
||||
// Reassign the position of mouse
|
||||
this.mouseLocation = mouseLocation
|
||||
}
|
||||
|
||||
unclicked() {
|
||||
if (!this.started) {
|
||||
this.blueprint.unselectAll()
|
||||
this.target.setSelected(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user