From 4bd8b5ce3286d472fd852dc53ef07e90aadfb7e9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 9 Feb 2012 08:47:33 -0800 Subject: Fixed runtime error when using 3d tools without any items selected. Signed-off-by: Nivesh Rajbhandari --- js/tools/Rotate3DToolBase.js | 2 +- js/tools/RotateStage3DTool.js | 2 +- js/tools/modifier-tool-base.js | 35 +++++++++++++++++++++-------------- 3 files changed, 23 insertions(+), 16 deletions(-) (limited to 'js/tools') diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js index 6e17864b..aa91b2f4 100644 --- a/js/tools/Rotate3DToolBase.js +++ b/js/tools/Rotate3DToolBase.js @@ -254,7 +254,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { captureSelectionDrawn: { value: function(event){ this._origin = null; - this._targets = null; + this._targets = []; this._startOriginArray = null; var len = this.application.ninja.selectedElements.length; diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index 6f07adae..ca2a8bf3 100644 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js @@ -83,7 +83,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { captureSelectionDrawn: { value: function(event){ this._origin = null; - this._targets = null; + this._targets = []; this._startOriginArray = null; var stage = this.application.ninja.currentDocument.documentRoot; diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index f78e99c8..67b217c4 100644 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -437,16 +437,19 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { startDraw: { value: function(event) { - this.isDrawing = true; - this.application.ninja.stage.showSelectionBounds = false; - - if(this._canSnap) - { - this.initializeSnapping(event); - } - else + if(this._target) { - this.drawWithoutSnapping(event); + this.isDrawing = true; + this.application.ninja.stage.showSelectionBounds = false; + + if(this._canSnap) + { + this.initializeSnapping(event); + } + else + { + this.drawWithoutSnapping(event); + } } } }, @@ -674,11 +677,15 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { return this._targets; }, set: function (value) { - this._target = value; - if (value === null) + this._targets = value; + if (value !== null && value.length) { - return; + this.target = value[0]; } + else + { + this.target = null; + } } }, @@ -723,7 +730,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { } else { this.eventManager.removeEventListener("selectionChange", this, true); this.application.ninja.stage._iframeContainer.removeEventListener("scroll", this, false); - this._targets = null; + this._targets = []; // Clean up NJevent("disableStageMove"); @@ -749,7 +756,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { captureSelectionDrawn: { value: function(event){ - this._targets = null; + this._targets = []; var len = this.application.ninja.selectedElements.length; if(len) -- cgit v1.2.3