feature : add keyboard shortcuts : initial impl

+ added shortcuts for all tools in ToolController
+ modified structure of tools in Controller to Array of descriptors to
allow to declare shortcuts directly when setting up the tool controller
This commit is contained in:
jdescottes
2013-11-17 22:07:26 +01:00
parent 25e6470499
commit f0ef016309
4 changed files with 64 additions and 36 deletions

View File

@ -11,6 +11,13 @@
"v" : Events.PASTE
}
};
// See ToolController
// TODO : Allow for other classes to register new shortcuts
var toolKeys = 'pveblrcmzso'.split('');
toolKeys.forEach(function (key) {
this.keyboardActions_[key] = Events.SELECT_TOOL;
}.bind(this));
};
@ -34,12 +41,14 @@
if(charkey) {
if (this.isCtrlKeyPressed_(evt)) {
eventToTrigger = this.keyboardActions_.ctrl[charkey];
} else {
eventToTrigger = this.keyboardActions_[charkey];
}
}
if(eventToTrigger) {
$.publish(eventToTrigger);
evt.preventDefault();
if(eventToTrigger) {
$.publish(eventToTrigger, charkey);
evt.preventDefault();
}
}
};

View File

@ -1,7 +1,7 @@
(function () {
var specialKeys = {};
var ns = $.namespace('service.keyboard');
var ns = $.namespace('pskl.service.keyboard');
ns.KeycodeTranslator= {
toChar : function (keycode) {