aboutsummaryrefslogtreecommitdiff
path: root/js/mediators/keyboard-mediator.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/mediators/keyboard-mediator.js')
-rwxr-xr-xjs/mediators/keyboard-mediator.js76
1 files changed, 23 insertions, 53 deletions
diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js
index f8934669..e2e8e937 100755
--- a/js/mediators/keyboard-mediator.js
+++ b/js/mediators/keyboard-mediator.js
@@ -67,7 +67,7 @@ exports.KeyboardMediator = Montage.create(Component, {
67 document.addEventListener("keydown", this, false); 67 document.addEventListener("keydown", this, false);
68 document.addEventListener("keyup", this, false); 68 document.addEventListener("keyup", this, false);
69 69
70 this.addEventListener("change@appModel.livePreview", this.handleLivePreview, false); 70 this.addPropertyChangeListener("appModel.livePreview", this.handleLivePreview, false);
71 } 71 }
72 }, 72 },
73 73
@@ -87,7 +87,8 @@ exports.KeyboardMediator = Montage.create(Component, {
87 value: function(evt) { 87 value: function(evt) {
88 88
89 //keyboard controls for html design view 89 //keyboard controls for html design view
90 if((!!this.application.ninja.documentController.activeDocument) && (this.application.ninja.documentController.activeDocument.currentView === "design")){ 90 // TODO - New template mode doesn't set currentView yet.
91 if((!!this.application.ninja.currentDocument) && (this.application.ninja.currentDocument.currentView === "design")) {
91 92
92 // Don't do anything if an input or other control is focused 93 // Don't do anything if an input or other control is focused
93 if(document.activeElement.nodeName !== "BODY") { 94 if(document.activeElement.nodeName !== "BODY") {
@@ -110,35 +111,35 @@ exports.KeyboardMediator = Montage.create(Component, {
110 // Shortcut for Selection Tool is V 111 // Shortcut for Selection Tool is V
111 if(evt.keyCode === Keyboard.V) { 112 if(evt.keyCode === Keyboard.V) {
112 evt.preventDefault(); 113 evt.preventDefault();
113 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[0]}); 114 this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.selectionToolIndex] });
114 return; 115 return;
115 } 116 }
116 117
117 // Shortcut for Tag Tool is D 118 // Shortcut for Tag Tool is D
118 if(evt.keyCode === Keyboard.D){ 119 if(evt.keyCode === Keyboard.D){
119 evt.preventDefault(); 120 evt.preventDefault();
120 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[4]}); 121 this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.tagToolIndex] });
121 return; 122 return;
122 } 123 }
123 124
124 // Shortcut for Rotate Tool is W 125 // Shortcut for Rotate Tool is W
125 if(evt.keyCode === Keyboard.W){ 126 if(evt.keyCode === Keyboard.W){
126 evt.preventDefault(); 127 evt.preventDefault();
127 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[2]}); 128 this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.rotate3DToolIndex] });
128 return; 129 return;
129 } 130 }
130 131
131 // Shortcut for Translate Tool is G 132 // Shortcut for Translate Tool is G
132 if(evt.keyCode === Keyboard.G){ 133 if(evt.keyCode === Keyboard.G){
133 evt.preventDefault(); 134 evt.preventDefault();
134 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[3]}); 135 this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.translate3DToolIndex] });
135 return; 136 return;
136 } 137 }
137 138
138 // shortcut for Pen tool is P 139 // shortcut for Pen tool is P
139 if (evt.keyCode === Keyboard.P){ 140 if (evt.keyCode === Keyboard.P){
140 evt.preventDefault(); 141 evt.preventDefault();
141 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[5]}); 142 this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.penToolIndex] });
142 return; 143 return;
143 } 144 }
144 145
@@ -147,24 +148,24 @@ exports.KeyboardMediator = Montage.create(Component, {
147 // If the user is pressing the command key, they want to refresh the browser. 148 // If the user is pressing the command key, they want to refresh the browser.
148 if((evt.keyCode === Keyboard.R) && !evt.metaKey) { 149 if((evt.keyCode === Keyboard.R) && !evt.metaKey) {
149 evt.preventDefault(); 150 evt.preventDefault();
150 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); 151 this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex] });
151 this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[1]}); 152 this.application.ninja.handleSelectSubTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex].subtools[1] });
152 return; 153 return;
153 } 154 }
154 155
155 // Shortcut for Oval Tool is O 156 // Shortcut for Oval Tool is O
156 if(evt.keyCode === Keyboard.O) { 157 if(evt.keyCode === Keyboard.O) {
157 evt.preventDefault(); 158 evt.preventDefault();
158 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); 159 this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex] });
159 this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[0]}); 160 this.application.ninja.handleSelectSubTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex].subtools[0] });
160 return; 161 return;
161 } 162 }
162 163
163 // Shortcut for Line Tool is L 164 // Shortcut for Line Tool is L
164 if(evt.keyCode === Keyboard.L ) { 165 if(evt.keyCode === Keyboard.L ) {
165 evt.preventDefault(); 166 evt.preventDefault();
166 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); 167 this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex] });
167 this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[2]}); 168 this.application.ninja.handleSelectSubTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex].subtools[2] });
168 return; 169 return;
169 } 170 }
170 171
@@ -172,38 +173,33 @@ exports.KeyboardMediator = Montage.create(Component, {
172 if(evt.keyCode === Keyboard.K ) { 173 if(evt.keyCode === Keyboard.K ) {
173 evt.preventDefault(); 174 evt.preventDefault();
174 if(this.application.ninja.toolsData.selectedTool.id === "FillTool") { 175 if(this.application.ninja.toolsData.selectedTool.id === "FillTool") {
175 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[11]}); 176 this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.inkBottleToolIndex] });
177 } else if(this.application.ninja.toolsData.selectedTool.id === "InkBottleTool") {
178 this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.fillToolIndex] });
176 } else { 179 } else {
177 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[10]}); 180 this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.fillToolIndex] });
178 } 181 }
179 return; 182 return;
180 }
181
182 // Shortcut for Eyedropper Tool is I
183 if(evt.keyCode === Keyboard.I && !(evt.ctrlKey || evt.metaKey)) {
184 evt.preventDefault();
185 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[12]});
186 return;
187 } 183 }
188 184
189 // Rotate Stage Tool is M 185 // Rotate Stage Tool is M
190 if(evt.keyCode === Keyboard.M ) { 186 if(evt.keyCode === Keyboard.M ) {
191 evt.preventDefault(); 187 evt.preventDefault();
192 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[13]}); 188 this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.rotateStage3DToolIndex] });
193 return; 189 return;
194 } 190 }
195 191
196 // Hand tool 192 // Hand tool
197 if(evt.keyCode === Keyboard.H ) { 193 if(evt.keyCode === Keyboard.H ) {
198 evt.preventDefault(); 194 evt.preventDefault();
199 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[14]}); 195 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.panToolIndex]});
200 return; 196 return;
201 } 197 }
202 198
203 // Zoom tool 199 // Zoom tool
204 if((evt.keyCode === Keyboard.Z) && !(evt.ctrlKey || evt.metaKey) && !evt.shiftKey) {//ctrl or shift key not press with Z 200 if((evt.keyCode === Keyboard.Z) && !(evt.ctrlKey || evt.metaKey) && !evt.shiftKey) {//ctrl or shift key not press with Z
205 evt.preventDefault(); 201 evt.preventDefault();
206 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[15]}); 202 this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.zoomToolIndex]});
207 return; 203 return;
208 } 204 }
209 205
@@ -256,7 +252,7 @@ exports.KeyboardMediator = Montage.create(Component, {
256 handleKeyup: { 252 handleKeyup: {
257 value: function(evt) { 253 value: function(evt) {
258 //keyboard controls for html design view 254 //keyboard controls for html design view
259 if((!!this.application.ninja.documentController.activeDocument) && (this.application.ninja.documentController.activeDocument.currentView === "design")){ 255 if((!!this.application.ninja.currentDocument) && (this.application.ninja.currentDocument.currentView === "design")) {
260 if(document.activeElement.nodeName !== "BODY") { 256 if(document.activeElement.nodeName !== "BODY") {
261 // Don't do anything if an input or other control is focused 257 // Don't do anything if an input or other control is focused
262 return; 258 return;
@@ -265,31 +261,5 @@ exports.KeyboardMediator = Montage.create(Component, {
265 if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleKeyUp(evt); 261 if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleKeyUp(evt);
266 } 262 }
267 } 263 }
268 },
269
270 _handleKeydown: {
271 value: function(evt) {
272
273 // Check if cmd-shift-+/ctrl-shift-+ for toggling snapping
274 if(evt.shiftKey && (evt.ctrlKey || evt.metaKey) && (evt.keyCode === 187))
275 {
276 MainMenuModule.MenuActionManager.toggleSnapping("snap", !DocumentManagerModule.DocumentManager.activeDocument.snapping);
277 evt.preventDefault();
278 return;
279 }
280
281 if(evt.keyCode === Keyboard.PLUS && (evt.metaKey||evt.ctrlKey)) {
282 evt.preventDefault();
283 this._toolsList.action("zoomIn", evt);
284 return;
285 }
286
287 if(evt.keyCode === Keyboard.MINUS && (evt.metaKey || evt.ctrlKey)) {
288 evt.preventDefault();
289 this._toolsList.action("zoomOut", evt);
290 return;
291 }
292
293