From d54ee97aa165eae56ffd60d00ff6ff947c3ebf1f Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Wed, 6 May 2015 17:36:46 +0200 Subject: [PATCH] feat(keyboard): add tooling specific key bindings * space tool -> [s] * multi select -> [m] related to bpmn-io/bpmn-js#244 --- lib/Modeler.js | 2 +- lib/features/keyboard/BpmnKeyBindings.js | 30 ++++++++++++++++++++++++ lib/features/keyboard/index.js | 7 ++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 lib/features/keyboard/BpmnKeyBindings.js create mode 100644 lib/features/keyboard/index.js diff --git a/lib/Modeler.js b/lib/Modeler.js index efcabbdb..aeb3fec5 100644 --- a/lib/Modeler.js +++ b/lib/Modeler.js @@ -129,12 +129,12 @@ Modeler.prototype._interactionModules = [ Modeler.prototype._modelingModules = [ // modeling components - require('diagram-js/lib/features/keyboard'), require('diagram-js/lib/features/move'), require('diagram-js/lib/features/bendpoints'), require('diagram-js/lib/features/resize'), require('diagram-js/lib/features/space-tool'), require('diagram-js/lib/features/lasso-tool'), + require('./features/keyboard'), require('./features/snapping'), require('./features/modeling'), require('./features/context-pad'), diff --git a/lib/features/keyboard/BpmnKeyBindings.js b/lib/features/keyboard/BpmnKeyBindings.js new file mode 100644 index 00000000..9b6300b6 --- /dev/null +++ b/lib/features/keyboard/BpmnKeyBindings.js @@ -0,0 +1,30 @@ +'use strict'; + + +function BpmnKeyBindings(keyboard, spaceTool, lassoTool) { + + keyboard.addListener(function(key, modifiers) { + + if (keyboard.hasModifier(modifiers)) { + return; + } + + // S -> activate space tool + if (key === 83) { + spaceTool.activateSelection(); + + return true; + } + + // M -> activate multi select tool + if (key === 77) { + lassoTool.activateSelection(); + + return true; + } + }); +} + +BpmnKeyBindings.$inject = [ 'keyboard', 'spaceTool', 'lassoTool' ]; + +module.exports = BpmnKeyBindings; \ No newline at end of file diff --git a/lib/features/keyboard/index.js b/lib/features/keyboard/index.js new file mode 100644 index 00000000..4a523158 --- /dev/null +++ b/lib/features/keyboard/index.js @@ -0,0 +1,7 @@ +module.exports = { + __depends__: [ + require('diagram-js/lib/features/keyboard') + ], + __init__: [ 'bpmnKeyBindings' ], + bpmnKeyBindings: [ 'type', require('./BpmnKeyBindings') ] +}; \ No newline at end of file