|
@@ -14,10 +14,14 @@ SC.loadPackage({ 'Keyboard': {
|
|
comment: 'method comment',
|
|
comment: 'method comment',
|
|
code: function(){
|
|
code: function(){
|
|
|
|
|
|
- var self = this;
|
|
|
|
|
|
+ var self = this,
|
|
|
|
+ spaceBarDown = false;
|
|
|
|
|
|
|
|
|
|
document.addEventListener('keydown', function(evt){
|
|
document.addEventListener('keydown', function(evt){
|
|
|
|
+ if(evt.target.tagName === 'INPUT' || evt.target.tagName === 'TEXTAREA' ){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
self.do('processKeyEvent', evt);
|
|
self.do('processKeyEvent', evt);
|
|
}, false);
|
|
}, false);
|
|
|
|
|
|
@@ -28,18 +32,50 @@ SC.loadPackage({ 'Keyboard': {
|
|
this.set({ helperOverlay: helperOverlay })
|
|
this.set({ helperOverlay: helperOverlay })
|
|
|
|
|
|
document.addEventListener('keydown', function(evt){
|
|
document.addEventListener('keydown', function(evt){
|
|
|
|
+
|
|
|
|
+ if(evt.target.tagName === 'INPUT' || evt.target.tagName === 'TEXTAREA' ){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
if(evt.keyCode === 72){
|
|
if(evt.keyCode === 72){
|
|
|
|
+
|
|
var helperOverlay = self.get('helperOverlay');
|
|
var helperOverlay = self.get('helperOverlay');
|
|
helperOverlay.style.width = window.innerWidth + 'px';
|
|
helperOverlay.style.width = window.innerWidth + 'px';
|
|
helperOverlay.style.height = window.innerHeight + 'px';
|
|
helperOverlay.style.height = window.innerHeight + 'px';
|
|
document.body.appendChild(helperOverlay);
|
|
document.body.appendChild(helperOverlay);
|
|
|
|
+
|
|
|
|
+ } else if(evt.keyCode === 32){
|
|
|
|
+
|
|
|
|
+ if(spaceBarDown === false){
|
|
|
|
+ var myDocument = SuperGlue.get('document');
|
|
|
|
+ myDocument.set({ showOutlines: !myDocument.get('showOutlines') });
|
|
|
|
+ spaceBarDown = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+
|
|
}, false);
|
|
}, false);
|
|
|
|
|
|
document.addEventListener('keyup', function(evt){
|
|
document.addEventListener('keyup', function(evt){
|
|
|
|
+
|
|
|
|
+ if(evt.target.tagName === 'INPUT' || evt.target.tagName === 'TEXTAREA' ){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
if(evt.keyCode === 72){
|
|
if(evt.keyCode === 72){
|
|
|
|
+
|
|
document.body.removeChild(self.get('helperOverlay'));
|
|
document.body.removeChild(self.get('helperOverlay'));
|
|
|
|
+
|
|
|
|
+ } else if(evt.keyCode === 32){
|
|
|
|
+
|
|
|
|
+ if(spaceBarDown === true){
|
|
|
|
+ var myDocument = SuperGlue.get('document');
|
|
|
|
+ myDocument.set({ showOutlines: !myDocument.get('showOutlines') });
|
|
|
|
+ spaceBarDown = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+
|
|
}, false);
|
|
}, false);
|
|
|
|
|
|
|
|
|
|
@@ -51,8 +87,7 @@ SC.loadPackage({ 'Keyboard': {
|
|
comment: 'I process key events.',
|
|
comment: 'I process key events.',
|
|
code: function(evt){
|
|
code: function(evt){
|
|
|
|
|
|
- var self = this,
|
|
|
|
- relevant = true;
|
|
|
|
|
|
+ var relevant = true;
|
|
|
|
|
|
if(evt.ctrlKey){
|
|
if(evt.ctrlKey){
|
|
|
|
|
|
@@ -81,6 +116,8 @@ SC.loadPackage({ 'Keyboard': {
|
|
|
|
|
|
case 65:
|
|
case 65:
|
|
// Ctrl+A
|
|
// Ctrl+A
|
|
|
|
+
|
|
|
|
+ this.do('selectAll');
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
@@ -102,24 +139,70 @@ SC.loadPackage({ 'Keyboard': {
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
+ case 73:
|
|
|
|
+ // Ctrl+I
|
|
|
|
+
|
|
|
|
+ SuperGlue.get('document').get('documentMenu').do('callMenuItemAction', {
|
|
|
|
+ menuItem: 'MenuItemNewPage'
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 79:
|
|
|
|
+ // Ctrl+O
|
|
|
|
+
|
|
|
|
+ SuperGlue.get('document').get('documentMenu').do('callMenuItemAction', {
|
|
|
|
+ menuItem: 'MenuItemFileManager'
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+
|
|
case 83:
|
|
case 83:
|
|
// Ctrl+S
|
|
// Ctrl+S
|
|
- alert('ja SSSSS')
|
|
|
|
|
|
+
|
|
|
|
+ if(evt.shiftKey){
|
|
|
|
+ SuperGlue.get('document').get('documentMenu').do('callMenuItemAction', {
|
|
|
|
+ menuItem: 'MenuItemSaveAs'
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
|
|
+ SuperGlue.get('document').get('documentMenu').do('callMenuItemAction', {
|
|
|
|
+ menuItem: 'MenuItemSave'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
break;
|
|
break;
|
|
|
|
|
|
case 86:
|
|
case 86:
|
|
// Ctrl+V
|
|
// Ctrl+V
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ SuperGlue.get('selection').do('clearAll');
|
|
|
|
+
|
|
|
|
+ SuperGlue.get('document').get('documentMenu').do('callMenuItemAction', {
|
|
|
|
+ menuItem: 'MenuItemPaste'
|
|
|
|
+ });
|
|
|
|
+
|
|
break;
|
|
break;
|
|
|
|
|
|
case 89:
|
|
case 89:
|
|
// Ctrl+Y
|
|
// Ctrl+Y
|
|
|
|
+
|
|
|
|
+ SuperGlue.get('selection').do('clearAll');
|
|
|
|
|
|
|
|
+ SuperGlue.get('document').get('documentMenu').do('callMenuItemAction', {
|
|
|
|
+ menuItem: 'MenuItemRedo'
|
|
|
|
+ });
|
|
|
|
+
|
|
break;
|
|
break;
|
|
|
|
|
|
case 90:
|
|
case 90:
|
|
// Ctrl+Z
|
|
// Ctrl+Z
|
|
|
|
+
|
|
|
|
+ SuperGlue.get('selection').do('clearAll');
|
|
|
|
|
|
|
|
+ SuperGlue.get('document').get('documentMenu').do('callMenuItemAction', {
|
|
|
|
+ menuItem: 'MenuItemUndo'
|
|
|
|
+ });
|
|
|
|
+
|
|
break;
|
|
break;
|
|
|
|
|
|
default:
|
|
default:
|
|
@@ -141,28 +224,32 @@ SC.loadPackage({ 'Keyboard': {
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
- case 32:
|
|
|
|
- // Space
|
|
|
|
-
|
|
|
|
- break;
|
|
|
|
|
|
|
|
case 37:
|
|
case 37:
|
|
// ArrowLeft
|
|
// ArrowLeft
|
|
|
|
+
|
|
|
|
+ this.do('moveSelection', 'left');
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
case 38:
|
|
case 38:
|
|
// ArrowUp
|
|
// ArrowUp
|
|
|
|
+
|
|
|
|
+ this.do('moveSelection', 'up');
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
case 39:
|
|
case 39:
|
|
// ArrowRight
|
|
// ArrowRight
|
|
|
|
+
|
|
|
|
+ this.do('moveSelection', 'right');
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
case 40:
|
|
case 40:
|
|
// ArrowDown
|
|
// ArrowDown
|
|
|
|
+
|
|
|
|
+ this.do('moveSelection', 'down');
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
@@ -181,9 +268,75 @@ SC.loadPackage({ 'Keyboard': {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ selectAll: {
|
|
|
|
+ comment: 'I select all (Ctrl+A)',
|
|
|
|
+ code: function(){
|
|
|
|
+
|
|
|
|
+ for(var selection = SuperGlue.get('selection'),
|
|
|
|
+ allElements = SuperGlue.get('document').get('children'),
|
|
|
|
+ i = 0, l = allElements.length;
|
|
|
|
+ i < l; i++){
|
|
|
|
+
|
|
|
|
+ selection.do('addElement', allElements[i]);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ moveSelection: {
|
|
|
|
+ comment: 'I move the selected elements on arrow key strokes in the given direction.',
|
|
|
|
+ code: function(direction){
|
|
|
|
+
|
|
|
|
+ var elements = SuperGlue.get('selection').get('elements'),
|
|
|
|
+ stepSize = SuperGlue.get('document').get('grid').get('active')
|
|
|
|
+ ? SuperGlue.get('document').get('grid').get('gridSize')
|
|
|
|
+ : 1,
|
|
|
|
+ layout = SuperGlue.get('document').get('layout');
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for(var i = 0, l = elements.length; i < l; i++){
|
|
|
|
+
|
|
|
|
+ switch(direction){
|
|
|
|
+
|
|
|
|
+ case 'up':
|
|
|
|
+ elements[i].set({ top: (elements[i].get('top') - stepSize) });
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 'down':
|
|
|
|
+ elements[i].set({ top: (elements[i].get('top') + stepSize) });
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 'left':
|
|
|
|
+ elements[i].set({ left: (elements[i].get('left') - stepSize) });
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 'right':
|
|
|
|
+ if(layout.centered){
|
|
|
|
+ if(layout.width >= elements[i].get('left') + elements[i].get('width') + stepSize){
|
|
|
|
+ elements[i].set({ left: (elements[i].get('left') + stepSize) });
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ elements[i].set({ left: (elements[i].get('left') + stepSize) });
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SuperGlue.get('selection').do('updateDimensions');
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|