From efabdc1053012a2a10d1db75179ea7ebbc4fcb0e Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 15 Jun 2012 10:58:18 -0700 Subject: Added correct 'Cancel' behavior to the material editor --- .../materials-popup.reel/materials-popup.js | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'js/panels/Materials') diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js index 91d50234..e9535f94 100755 --- a/js/panels/Materials/materials-popup.reel/materials-popup.js +++ b/js/panels/Materials/materials-popup.reel/materials-popup.js @@ -35,6 +35,7 @@ exports.MaterialsPopup = Montage.create(Component, { _useSelection: { value: false, enumerable: true }, _whichMaterial: { value: "fill", enumerable: true }, + _originalValues: {value: null, enumerable: true }, captureAction: { value:function(event) { @@ -42,6 +43,7 @@ exports.MaterialsPopup = Montage.create(Component, { { case "Cancel": console.log("Cancel material edit"); + this.revertToOriginalValues(); break; case "OK": console.log("Committing material with the following values:"); @@ -70,6 +72,46 @@ exports.MaterialsPopup = Montage.create(Component, { } }, + revertToOriginalValues: + { + value: function() + { + if (this._originalValues) + { + this._material.importJSON( this._originalValues ); + + if (this._useSelection) + { + var selection = this.application.ninja.selectedElements; + if (selection && (selection.length > 0)) + { + var nObjs = selection.length; + for (var iObj=0; iObj