From 596d0c4f5f37c9c8a499303be740b10380d311da Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Thu, 1 Nov 2018 14:13:07 -0400 Subject: [PATCH] Include the origin blockId of the top block being dragged. This is required by the GUI in order to take a snapshot of the blocks for the backpack. Only the ID is needed, the rest can be done by the GUI. --- src/engine/blocks.js | 2 +- src/engine/runtime.js | 5 +++-- src/virtual-machine.js | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/engine/blocks.js b/src/engine/blocks.js index 28ac3184f..858871f69 100644 --- a/src/engine/blocks.js +++ b/src/engine/blocks.js @@ -340,7 +340,7 @@ class Blocks { // Drag blocks onto another sprite if (e.isOutside) { const newBlocks = adapter(e); - optRuntime.emitBlockEndDrag(newBlocks); + optRuntime.emitBlockEndDrag(newBlocks, e.blockId); } } break; diff --git a/src/engine/runtime.js b/src/engine/runtime.js index 95d07aa09..26315a952 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -1857,9 +1857,10 @@ class Runtime extends EventEmitter { /** * Emit event to indicate that the block drag has ended with the blocks outside the blocks workspace * @param {Array.} blocks The set of blocks dragged to the GUI + * @param {string} topBlockId The original id of the top block being dragged */ - emitBlockEndDrag (blocks) { - this.emit(Runtime.BLOCK_DRAG_END, blocks); + emitBlockEndDrag (blocks, topBlockId) { + this.emit(Runtime.BLOCK_DRAG_END, blocks, topBlockId); } /** diff --git a/src/virtual-machine.js b/src/virtual-machine.js index b7659dd31..1aaae9578 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -96,8 +96,8 @@ class VirtualMachine extends EventEmitter { this.runtime.on(Runtime.BLOCK_DRAG_UPDATE, areBlocksOverGui => { this.emit(Runtime.BLOCK_DRAG_UPDATE, areBlocksOverGui); }); - this.runtime.on(Runtime.BLOCK_DRAG_END, blocks => { - this.emit(Runtime.BLOCK_DRAG_END, blocks); + this.runtime.on(Runtime.BLOCK_DRAG_END, (blocks, topBlockId) => { + this.emit(Runtime.BLOCK_DRAG_END, blocks, topBlockId); }); this.runtime.on(Runtime.EXTENSION_ADDED, blocksInfo => { this.emit(Runtime.EXTENSION_ADDED, blocksInfo);