aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorValerio Virgillito2012-03-14 18:04:11 -0700
committerValerio Virgillito2012-03-14 18:04:11 -0700
commita7cb2c0b22f03b79f19d4a9a2eb691d1ccc392f9 (patch)
tree8daf6d201890c1fb7f8dbffe492500d492ae96d7 /js
parente07ec7dd1a4b8df747f6af0d54fe95e3a237f0c8 (diff)
downloadninja-a7cb2c0b22f03b79f19d4a9a2eb691d1ccc392f9.tar.gz
adding a focus manager to handle panel bugs where blur was not getting called when clicking on the canvas.
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js')
-rw-r--r--js/components/focus-manager.reel/focus-manager.js49
-rwxr-xr-xjs/ninja.reel/ninja.css4
-rwxr-xr-xjs/ninja.reel/ninja.html11
-rwxr-xr-xjs/panels/properties.reel/properties.html2
-rwxr-xr-xjs/stage/stage.reel/stage.html7
-rwxr-xr-xjs/stage/stage.reel/stage.js4
6 files changed, 74 insertions, 3 deletions
diff --git a/js/components/focus-manager.reel/focus-manager.js b/js/components/focus-manager.reel/focus-manager.js
new file mode 100644
index 00000000..65a84bc1
--- /dev/null
+++ b/js/components/focus-manager.reel/focus-manager.js
@@ -0,0 +1,49 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6
7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component;
9
10exports.FocusManager = Montage.create(Component, {
11
12 hasTemplate: {
13 value: false
14 },
15
16 element: {
17 serializable: true,
18 enumerable: true,
19 get: function() {
20 return this._element;
21 },
22 set: function(value) {
23 // call super set
24 Object.getPropertyDescriptor(Component, "element").set.call(this, value);
25 }
26 },
27
28 hiddenInput: {
29 value: null
30 },
31
32 prepareForDraw: {
33 value: function() {
34 this.hiddenInput = document.createElement("input");
35 this.hiddenInput.type = "text";
36
37 this.element.appendChild(this.hiddenInput);
38
39 }
40 },
41
42 setFocus: {
43 value: function() {
44 this.hiddenInput.focus();
45 }
46 }
47
48});
49
diff --git a/js/ninja.reel/ninja.css b/js/ninja.reel/ninja.css
index 83c0e569..61251eff 100755
--- a/js/ninja.reel/ninja.css
+++ b/js/ninja.reel/ninja.css
@@ -7,3 +7,7 @@
7.main { 7.main {
8 padding: 100px; 8 padding: 100px;
9} 9}
10
11.hidden {
12 display: none;
13}
diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html
index 3dc45498..f9e1efdd 100755
--- a/js/ninja.reel/ninja.html
+++ b/js/ninja.reel/ninja.html
@@ -287,6 +287,13 @@
287 "name": "MainMenuController" 287 "name": "MainMenuController"
288 }, 288 },
289 289
290 "focusManager": {
291 "object": "js/components/focus-manager.reel",
292 "properties": {
293 "element": {"#": "focus-container" }
294 }
295 },
296
290 "owner": { 297 "owner": {
291 "module": "js/ninja.reel", 298 "module": "js/ninja.reel",
292 "name": "Ninja", 299 "name": "Ninja",
@@ -396,7 +403,9 @@
396 403
397 <section data-montage-id="bottomSplitter" class="bottomSplitter splitter"></section> 404 <section data-montage-id="bottomSplitter" class="bottomSplitter splitter"></section>
398 </section> 405 </section>
399 406
407 <div data-montage-id="focus-container" class="hidden"></div>
408
400 <section id="popupWindows"></section> 409 <section id="popupWindows"></section>
401 410
402 </div> 411 </div>
diff --git a/js/panels/properties.reel/properties.html b/js/panels/properties.reel/properties.html
index bcf54b95..d212ae80 100755
--- a/js/panels/properties.reel/properties.html
+++ b/js/panels/properties.reel/properties.html
@@ -125,7 +125,7 @@
125 </section> 125 </section>
126 <section class="fieldCol"> 126 <section class="fieldCol">
127 <label>Class:</label> 127 <label>Class:</label>
128 <article class="fieldRow"><input type="text" id="elementClassName" class="nj-skinned" /></article> 128 <article class="fieldRow"><input type="text" id="elementClass" class="nj-skinned" /></article>
129 </section> 129 </section>
130 </section> 130 </section>
131 <section id="PosSize"></section> 131 <section id="PosSize"></section>
diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html
index 812e3d55..f796303c 100755
--- a/js/stage/stage.reel/stage.html
+++ b/js/stage/stage.reel/stage.html
@@ -50,6 +50,10 @@
50 "element" : {"#": "textToolObject"} 50 "element" : {"#": "textToolObject"}
51 } 51 }
52 }, 52 },
53
54 "focusManager": {
55 "object": "js/components/focus-manager.reel"
56 },
53 57
54 "owner": { 58 "owner": {
55 "module": "js/stage/stage.reel", 59 "module": "js/stage/stage.reel",
@@ -63,7 +67,8 @@
63 "stageDeps": {"@": "StageDeps1"}, 67 "stageDeps": {"@": "StageDeps1"},
64 "layout": {"@": "layout1"}, 68 "layout": {"@": "layout1"},
65 "stageView": {"@": "stageView"}, 69 "stageView": {"@": "stageView"},
66 "textTool": {"@": "textTool"} 70 "textTool": {"@": "textTool"},
71 "focusManager": {"@": "focusManager"}
67 }, 72 },
68 "bindings": { 73 "bindings": {
69 "currentDocumentStageView": { 74 "currentDocumentStageView": {
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index 4c1d046b..a624b2c6 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -319,6 +319,10 @@ exports.Stage = Montage.create(Component, {
319 319
320 handleMousedown: { 320 handleMousedown: {
321 value: function(event) { 321 value: function(event) {
322 // Call the focus manager to set focus to blur any focus'd elements
323 this.focusManager.setFocus();
324
325
322 var point; 326 var point;
323// event.preventDefault(); // commenting because HTML elements in the IDE are retaining focus 327// event.preventDefault(); // commenting because HTML elements in the IDE are retaining focus
324 // If right click set the context menu to true to prevent a mouse up. 328 // If right click set the context menu to true to prevent a mouse up.