Browse Source

select recovered object after Delete-Undo or Add-Redo situation

Mario Schuettel 9 years ago
parent
commit
1483abe2f6

+ 1 - 0
editor/js/CmdAddObject.js

@@ -27,6 +27,7 @@ CmdAddObject.prototype = {
 	execute: function () {
 	execute: function () {
 
 
 		this.editor.addObject( this.object );
 		this.editor.addObject( this.object );
+		this.editor.select( this.object );
 
 
 	},
 	},
 
 

+ 1 - 0
editor/js/CmdRemoveObject.js

@@ -57,6 +57,7 @@ CmdRemoveObject.prototype = {
 
 
 		this.parent.children.splice( this.index, 0, this.object );
 		this.parent.children.splice( this.index, 0, this.object );
 		this.object.parent = this.parent;
 		this.object.parent = this.parent;
+		this.editor.select( this.object );
 
 
 		this.editor.signals.objectAdded.dispatch( this.object );
 		this.editor.signals.objectAdded.dispatch( this.object );
 		this.editor.signals.sceneGraphChanged.dispatch();
 		this.editor.signals.sceneGraphChanged.dispatch();

+ 5 - 1
test/unit/editor/TestCmdAddObjectAndCmdRemoveObject.js

@@ -14,7 +14,7 @@ test( "Test CmdAddObject and CmdRemoveObject (Undo and Redo)", function() {
 	var light = aPointlight( 'The PointLight' );
 	var light = aPointlight( 'The PointLight' );
 	var camera = aPerspectiveCamera( 'The Camera' );
 	var camera = aPerspectiveCamera( 'The Camera' );
 
 
-	var objects = [ box, light, camera ];
+	var objects = [ box , light, camera ];
 
 
 	objects.map( function( object ) {
 	objects.map( function( object ) {
 
 
@@ -31,6 +31,8 @@ test( "Test CmdAddObject and CmdRemoveObject (Undo and Redo)", function() {
 		editor.redo();
 		editor.redo();
 		ok( editor.scene.children[ 0 ].name == object.name, "OK, removed '" + object.type + "' was added again (redo)" );
 		ok( editor.scene.children[ 0 ].name == object.name, "OK, removed '" + object.type + "' was added again (redo)" );
 
 
+		ok( editor.selected == object, "OK, focus was set on recovered object after Add-Redo" );
+
 
 
 		// Test Remove
 		// Test Remove
 		var cmd = new CmdRemoveObject( object );
 		var cmd = new CmdRemoveObject( object );
@@ -42,6 +44,8 @@ test( "Test CmdAddObject and CmdRemoveObject (Undo and Redo)", function() {
 		editor.undo();
 		editor.undo();
 		ok( editor.scene.children[ 0 ].name == object.name, "OK, removed object was added again (undo)" );
 		ok( editor.scene.children[ 0 ].name == object.name, "OK, removed object was added again (undo)" );
 
 
+		ok( editor.selected == object, "OK, focus was set on recovered object after Delete-Undo" );
+
 		editor.redo();
 		editor.redo();
 		ok( editor.scene.children.length == 0, "OK, object was removed again (redo)" );
 		ok( editor.scene.children.length == 0, "OK, object was removed again (redo)" );