editor: enable lasso when mod is pressed

This commit is contained in:
jean-emmanuel 2018-10-10 18:56:18 +02:00
parent 9c421e2f47
commit ec37bb8e00

View file

@ -6,7 +6,7 @@ var {widgets} = require('../widgets/'),
widgetManager = require('../managers/widgets'),
{deepCopy} = require('../utils'),
macOs = (navigator.platform || '').match('Mac'),
modKey = macOs ? 'metaKey' : 'ctrlKey',
modKey = macOs ? 'command' : 'ctrl',
sessionManager
const HISTORY_SIZE = 50
@ -43,6 +43,7 @@ var Editor = class Editor {
this.defaults[k] = widgets[k].defaults()
}
this.selecting = false
this.selectedWidgets = []
this.clipboard = null
@ -89,6 +90,12 @@ var Editor = class Editor {
if (e.target.classList.contains('no-keybinding')) return
this.pasteWidget(this.mousePosition.x, this.mousePosition.y, true)
})
keyboardJS.bind(modKey, (e)=>{
if (e.target.classList.contains('no-keybinding')) return
$('#container').selectable('enable')
}, (e)=>{
if (!this.selecting) $('#container').selectable('disable')
})
keyboardJS.bind(macOs ? 'backspace' : 'delete', (e)=>{
if (e.target.classList.contains('no-keybinding')) return
this.deleteWidget()
@ -259,6 +266,7 @@ var Editor = class Editor {
disabled: true,
start: (e)=>{
tmpSelection = []
this.selecting = true
},
selected: (ev, ui)=>{
var widget = widgetManager.getWidgetByElement(ui.selected)
@ -269,6 +277,8 @@ var Editor = class Editor {
this.select(tmpSelection[i], {multi:true, fromLasso:true})
}
this.select(this.selectedWidgets)
this.selecting = false
$('#container').selectable('disable')
}
})