2015-05-06 15:36:46 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-07-22 16:08:53 +00:00
|
|
|
function BpmnKeyBindings(
|
|
|
|
keyboard, spaceTool, lassoTool,
|
|
|
|
directEditing, selection, canvas,
|
|
|
|
elementRegistry) {
|
2015-05-06 15:36:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
keyboard.addListener(function(key, modifiers) {
|
|
|
|
|
2015-07-22 16:08:53 +00:00
|
|
|
// ctrl + a -> select all elements
|
|
|
|
if (key === 65 && keyboard.isCmd(modifiers)) {
|
|
|
|
|
|
|
|
// select all elements except for the invisible
|
|
|
|
// root element
|
|
|
|
var rootElement = canvas.getRootElement();
|
|
|
|
|
|
|
|
var elements = elementRegistry.filter(function(element) {
|
|
|
|
return element != rootElement;
|
|
|
|
});
|
|
|
|
|
|
|
|
selection.select(elements);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-05-06 15:36:46 +00:00
|
|
|
if (keyboard.hasModifier(modifiers)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-26 12:06:16 +00:00
|
|
|
// s -> activate space tool
|
2015-05-06 15:36:46 +00:00
|
|
|
if (key === 83) {
|
|
|
|
spaceTool.activateSelection();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-05-26 12:06:16 +00:00
|
|
|
// l -> activate lasso tool
|
|
|
|
if (key === 76) {
|
2015-05-06 15:36:46 +00:00
|
|
|
lassoTool.activateSelection();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-05-06 16:09:13 +00:00
|
|
|
|
|
|
|
var currentSelection = selection.get();
|
|
|
|
|
2015-05-26 12:06:16 +00:00
|
|
|
// e -> activate direct editing
|
2015-05-06 16:09:13 +00:00
|
|
|
if (key === 69) {
|
|
|
|
if (currentSelection.length) {
|
|
|
|
directEditing.activate(currentSelection[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-05-06 15:36:46 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-07-22 16:08:53 +00:00
|
|
|
BpmnKeyBindings.$inject = [
|
|
|
|
'keyboard',
|
|
|
|
'spaceTool',
|
|
|
|
'lassoTool',
|
|
|
|
'directEditing',
|
|
|
|
'selection',
|
|
|
|
'canvas',
|
|
|
|
'elementRegistry'
|
|
|
|
];
|
2015-05-06 15:36:46 +00:00
|
|
|
|
2015-07-22 16:08:53 +00:00
|
|
|
module.exports = BpmnKeyBindings;
|