editor: alt+c+drag to drag+copy widgets

This commit is contained in:
jean-emmanuel 2021-03-15 22:47:44 +01:00
parent d2e43a4689
commit 85cb1ede51
5 changed files with 34 additions and 5 deletions

View file

@ -38,11 +38,13 @@ class UiDragResize extends UiWidget {
this.handles = DOM.get(this.container, '.handle')
this.dragging = null
this.copying = null
this.shiftKey = false
this.on('draginit', (event)=>{
var node = event.firstTarget
if (event.shiftKey || !this.handles.includes(node)) return
if ((event.shiftKey && !event.altKey) || !this.handles.includes(node)) return
this.initLeft = this.left
this.initTop = this.top
@ -85,14 +87,19 @@ class UiDragResize extends UiWidget {
this.on('dragend', (event)=>{
if (!this.dragging) return
var node = event.firstTarget
if (!this.handles.includes(node)) return
this.container.classList.remove('dragging')
this.left = Math.max(0, this.left)
this.top = Math.max(0, this.top)
this.shiftKey = event.shiftKey
this.trigger(this.dragging.indexOf('left') > -1 ? 'move' : 'drag-resize', this)
this.dragging = null
this.copying = null
this.shiftKey = false
}, {element: this.container})
@ -108,6 +115,13 @@ class UiDragResize extends UiWidget {
}, (e)=>{
this.handles[0].classList.remove('full')
})
keyboardJS.bind('alt+c', (e)=>{
this.copying = true
this.container.classList.add('copying')
}, (e)=>{
this.copying = false
this.container.classList.remove('copying')
})
})
}

View file

@ -25,7 +25,7 @@ class UiSelectArea {
}
mousedown(e) {
if (!e.shiftKey || event.button === 2) return
if (!e.shiftKey || event.altKey || event.button === 2) return
this.startX = this.curX = e.clientX
this.startY = this.curY = e.clientY
this.down = true