mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-05-16 00:12:55 -04:00
Create a new input if one doesn't exist (#148)
* Create a new input if one doesn't exist * Add regression tests for move-into-empty and obscuring shadows via move
This commit is contained in:
parent
f7e339f7c2
commit
14feb64005
2 changed files with 70 additions and 3 deletions
src/engine
|
@ -249,9 +249,15 @@ Blocks.prototype.moveBlock = function (e) {
|
|||
if (e.newInput !== undefined) {
|
||||
// Moved to the new parent's input.
|
||||
// Don't obscure the shadow block.
|
||||
var newInput = this._blocks[e.newParent].inputs[e.newInput];
|
||||
newInput.name = e.newInput;
|
||||
newInput.block = e.id;
|
||||
var oldShadow = null;
|
||||
if (this._blocks[e.newParent].inputs.hasOwnProperty(e.newInput)) {
|
||||
oldShadow = this._blocks[e.newParent].inputs[e.newInput].shadow;
|
||||
}
|
||||
this._blocks[e.newParent].inputs[e.newInput] = {
|
||||
name: e.newInput,
|
||||
block: e.id,
|
||||
shadow: oldShadow
|
||||
};
|
||||
} else {
|
||||
// Moved to the new parent's next connection.
|
||||
this._blocks[e.newParent].next = e.id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue