mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-13 06:57:28 +08:00
Drag nodes using arrows
This commit is contained in:
@@ -207,10 +207,10 @@ export default class Configuration {
|
||||
"PageDown": "PageDown",
|
||||
"End": "End",
|
||||
"Home": "Home",
|
||||
"ArrowLeft": "Left",
|
||||
"ArrowUp": "Up",
|
||||
"ArrowRight": "Right",
|
||||
"ArrowDown": "Down",
|
||||
"ArrowLeft": "ArrowLeft",
|
||||
"ArrowUp": "ArrowUp",
|
||||
"ArrowRight": "ArrowRight",
|
||||
"ArrowDown": "ArrowDown",
|
||||
"PrintScreen": "PrintScreen",
|
||||
"Insert": "Insert",
|
||||
"Delete": "Delete",
|
||||
|
||||
@@ -14,6 +14,8 @@ export default class IKeyboardShortcut extends IInput {
|
||||
/** @type {KeyBindingEntity[]} */
|
||||
#activationKeys
|
||||
|
||||
pressedKey = ""
|
||||
|
||||
/**
|
||||
* @param {T} target
|
||||
* @param {Blueprint} blueprint
|
||||
@@ -65,6 +67,7 @@ export default class IKeyboardShortcut extends IInput {
|
||||
e.preventDefault()
|
||||
e.stopImmediatePropagation()
|
||||
}
|
||||
this.pressedKey = e.code
|
||||
self.fire()
|
||||
document.removeEventListener("keydown", self.keyDownHandler)
|
||||
document.addEventListener("keyup", self.keyUpHandler)
|
||||
@@ -87,6 +90,7 @@ export default class IKeyboardShortcut extends IInput {
|
||||
e.stopImmediatePropagation()
|
||||
}
|
||||
self.unfire()
|
||||
this.pressedKey = ""
|
||||
document.removeEventListener("keyup", this.keyUpHandler)
|
||||
document.addEventListener("keydown", this.keyDownHandler)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import Configuration from "../Configuration.js"
|
||||
import ITemplate from "./ITemplate.js"
|
||||
import KeyboardShortcutAction from "../input/keybaord/KeyboardShortcutAction.js"
|
||||
import MouseMoveDraggable from "../input/mouse/MouseMoveDraggable.js"
|
||||
|
||||
/**
|
||||
@@ -26,6 +28,30 @@ export default class IDraggableTemplate extends ITemplate {
|
||||
return [
|
||||
...super.createInputObjects(),
|
||||
this.createDraggableObject(),
|
||||
new KeyboardShortcutAction(
|
||||
this.element,
|
||||
this.blueprint,
|
||||
{
|
||||
activationKeys: [
|
||||
Configuration.Keys.ArrowUp,
|
||||
Configuration.Keys.ArrowRight,
|
||||
Configuration.Keys.ArrowDown,
|
||||
Configuration.Keys.ArrowLeft,
|
||||
]
|
||||
},
|
||||
self => self.target.acknowledgeDrag([
|
||||
self.pressedKey === Configuration.Keys.ArrowLeft
|
||||
? -Configuration.gridSize
|
||||
: self.pressedKey === Configuration.Keys.ArrowRight
|
||||
? Configuration.gridSize
|
||||
: 0,
|
||||
self.pressedKey === Configuration.Keys.ArrowUp
|
||||
? -Configuration.gridSize
|
||||
: self.pressedKey === Configuration.Keys.ArrowDown
|
||||
? Configuration.gridSize
|
||||
: 0,
|
||||
])
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user