Fix event propagation for keyboard events.

This commit is contained in:
Paulo Gustavo Veiga 2012-07-06 00:55:35 -03:00
parent b816d12842
commit d921cecb19

View File

@ -42,9 +42,10 @@ mindplot.DesignerKeyboard = new Class({
var model = designer.getModel(); var model = designer.getModel();
var keyboardEvents = { var keyboardEvents = {
'backspace':function (event) { 'backspace':function (event) {
designer.deleteCurrentNode();
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
designer.deleteCurrentNode();
}.bind(this), }.bind(this),
@ -71,79 +72,130 @@ mindplot.DesignerKeyboard = new Class({
designer.createChildForSelectedNode(); designer.createChildForSelectedNode();
}.bind(this), }.bind(this),
'meta+enter':function () { 'meta+enter':function (event) {
designer.createChildForSelectedNode(); designer.createChildForSelectedNode();
event.preventDefault();
event.stopPropagation();
}.bind(this), }.bind(this),
'ctrl+z':function () { 'ctrl+z':function () {
designer.undo(); designer.undo();
event.preventDefault(event);
event.stopPropagation();
}.bind(this), }.bind(this),
'meta+z':function () { 'meta+z':function (event) {
designer.undo(); designer.undo();
event.preventDefault();
event.stopPropagation();
}.bind(this), }.bind(this),
'ctrl+z+shift':function () { 'ctrl+z+shift':function (event) {
designer.redo(); designer.redo();
event.preventDefault();
event.stopPropagation();
}.bind(this), }.bind(this),
'meta+z+shift':function () { 'meta+z+shift':function (event) {
designer.redo(); designer.redo();
event.preventDefault();
event.stopPropagation();
}.bind(this), }.bind(this),
'ctrl+y':function () { 'ctrl+y':function (event) {
designer.redo(); designer.redo();
event.preventDefault();
event.stopPropagation();
}.bind(this), }.bind(this),
'meta+y':function () { 'meta+y':function (event) {
designer.redo(); designer.redo();
event.preventDefault();
event.stopPropagation();
}.bind(this), }.bind(this),
'ctrl+a':function (event) { 'ctrl+a':function (event) {
designer.selectAll(); designer.selectAll();
event.preventDefault(); event.preventDefault();
event.stopPropagation();
}, },
'ctrl+b':function () { 'ctrl+b':function (event) {
designer.changeFontWeight(); designer.changeFontWeight();
event.preventDefault();
event.stopPropagation();
}, },
'meta+b':function () { 'meta+b':function (event) {
designer.changeFontWeight(); designer.changeFontWeight();
event.preventDefault();
event.stopPropagation();
}, },
'ctrl+s':function (event) { 'ctrl+s':function (event) {
event.preventDefault(); event.preventDefault();
$('save').fireEvent('click'); $('save').fireEvent('click');
event.preventDefault();
event.stopPropagation();
}, },
'meta+s':function (event) { 'meta+s':function (event) {
event.preventDefault(); event.preventDefault();
$('save').fireEvent('click'); $('save').fireEvent('click');
event.preventDefault();
event.stopPropagation();
}, },
'ctrl+i':function () { 'ctrl+i':function (event) {
designer.changeFontStyle(); designer.changeFontStyle();
event.preventDefault();
event.stopPropagation();
}, },
'meta+i':function () { 'meta+i':function (event) {
designer.changeFontStyle(); designer.changeFontStyle();
event.preventDefault();
event.stopPropagation();
}, },
'meta+shift+a':function (event) { 'meta+shift+a':function (event) {
designer.deselectAll(); designer.deselectAll();
event.preventDefault(); event.preventDefault();
event.stopPropagation();
}, },
'ctrl+shift+a':function (event) { 'ctrl+shift+a':function (event) {
designer.deselectAll(); designer.deselectAll();
event.preventDefault();
event.preventDefault();
event.stopPropagation();
}, },
'meta+a':function (event) { 'meta+a':function (event) {
designer.selectAll(); designer.selectAll();
event.preventDefault(); event.preventDefault();
event.stopPropagation();
}, },
'right':function () { 'right':function () {