From a11ef2eed7049835c8bdfa50a2b893632c46eaa0 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 4 Apr 2012 11:11:58 -0700 Subject: Squashed commit of Preparing for the montage undo-manager: Architecture changes Reworked the add and remove elements into 1 function which can take 1 or more elements. Removed the _element from the selection array Many other changes related to those 2 changes Undo/Redo shortcuts are now using montage undo/redo manager. Signed-off-by: Valerio Virgillito --- js/mediators/keyboard-mediator.js | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) (limited to 'js/mediators/keyboard-mediator.js') diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index fc0d0f6a..82596693 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -99,12 +99,11 @@ exports.KeyboardMediator = Montage.create(Component, { evt.preventDefault(); } - // Check DELETE OR BACKSPACE + // DELETE or BACKSPACE event handler - Removes the current selected elements from the DOM if((evt.keyCode == Keyboard.BACKSPACE) || (evt.keyCode == Keyboard.DELETE)) { evt.stopImmediatePropagation(); evt.preventDefault(); - NJevent("deleting"); - return; + return this.application.ninja.elementMediator.removeElements(document.application.ninja.selectedElements); } @@ -197,9 +196,7 @@ exports.KeyboardMediator = Montage.create(Component, { } if(evt.keyCode === Keyboard.ESCAPE){//ESC key - //console.log("ESC key pressed"); if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleEscape(evt); - //menuViewManagerModule.MenuViewManager.closeMenu("mainMenuBar"); } @@ -214,37 +211,27 @@ exports.KeyboardMediator = Montage.create(Component, { // Check if cmd+z/ctrl+z for Undo (Windows/Mac) if ((evt.keyCode == Keyboard.Z) && (evt.ctrlKey || evt.metaKey) && !evt.shiftKey) { - NJevent("executeUndo"); - //menuViewManagerModule.MenuViewManager.closeMenu("mainMenuBar"); - return; - } - - // Check if cmd+s/ctrl+s for Save (Windows/Mac) - if ((evt.keyCode == Keyboard.S) && (evt.ctrlKey || evt.metaKey) && !evt.shiftKey) { - try{ - NJevent("executeSave"); - } - catch(e){ - console.warn("Unable to save"); - console.log(e.stack); - } - evt.preventDefault(); + document.application.undoManager.undo(); return; } // Check if cmd+shift+z for Redo (Mac) if ((evt.keyCode == Keyboard.Z) && evt.metaKey && evt.shiftKey) { - NJevent("executeRedo"); - //menuViewManagerModule.MenuViewManager.closeMenu("mainMenuBar"); + document.application.undoManager.redo(); return; } - // Check if ctrl+y for Redo (Windows) + // Check if ctrl+y for Redo (Windows) if ((evt.keyCode == Keyboard.Y) && evt.ctrlKey) { - NJevent("executeRedo"); - //menuViewManagerModule.MenuViewManager.closeMenu("mainMenuBar"); + document.application.undoManager.redo(); return; } + + // Check if cmd+s/ctrl+s for Save (Windows/Mac) + if ((evt.keyCode == Keyboard.S) && (evt.ctrlKey || evt.metaKey) && !evt.shiftKey) { + NJevent("executeSave"); + evt.preventDefault(); + } } }, -- cgit v1.2.3