Fix some keyboard problems with modifiers.

This commit is contained in:
Paulo Veiga 2012-01-21 18:24:55 -03:00
parent 0e07e28b4c
commit db645859ae

View File

@ -33,6 +33,8 @@ mindplot.DesignerKeyboard = new Class({
'backspace':function(event) { 'backspace':function(event) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
designer.deleteCurrentNode();
}.bind(this), }.bind(this),
'space' : function() { 'space' : function() {
@ -199,7 +201,7 @@ mindplot.DesignerKeyboard = new Class({
var regex = /^(?:shift|control|ctrl|alt|meta)$/; var regex = /^(?:shift|control|ctrl|alt|meta)$/;
var modifiers = ['shift', 'control', 'alt', 'meta']; var modifiers = ['shift', 'control', 'alt', 'meta'];
var excludes = ['esc','capslock','tab','f1','f3','f4','f5','f6','f7','f8','f9','f10','f11','f12']; var excludes = ['esc','capslock','tab','f1','f3','f4','f5','f6','f7','f8','f9','f10','f11','f12','backspace','down','up','left','right'];
$(document).addEvent('keydown', function(event) { $(document).addEvent('keydown', function(event) {
@ -222,13 +224,13 @@ mindplot.DesignerKeyboard = new Class({
} }
// If it's not registered, let's // If it's not registered, let's
if (!isRegistered && !excludes.contains(key) && 'meta+[' != key) { if (!isRegistered && !excludes.contains(key) && !excludes.contains(event.key) && 'meta+[' != key) {
var nodes = designer.getModel().filterSelectedTopics(); var nodes = designer.getModel().filterSelectedTopics();
if (nodes.length > 0) { if (nodes.length > 0) {
// If a modifier is press, the key selected must be ignored. // If a modifier is press, the key selected must be ignored.
var pressKey = event.key; var pressKey = event.key;
if (modifiers.contains(key)) { if (modifiers.contains(event.key)) {
pressKey = ""; pressKey = "";
} }