diff --git a/src/engine/runtime.js b/src/engine/runtime.js index 7e66abc31..65ba0ac1f 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -51,6 +51,7 @@ Runtime.THREAD_STEP_INTERVAL = 1000 / 60; * @param {!Object} block Blockly create event to be processed */ Runtime.prototype.createBlock = function (block) { +Runtime.prototype.createBlock = function (block, opt_isFlyoutBlock) { // Create new block this.blocks[block.id] = block; @@ -67,7 +68,9 @@ Runtime.prototype.createBlock = function (block) { // Push block id to stacks array. New blocks are always a stack even if only // momentary. If the new block is added to an existing stack this stack will // be removed by the `moveBlock` method below. - this.stacks.push(block.id); + if (!opt_isFlyoutBlock) { + this.stacks.push(block.id); + } }; /** diff --git a/src/index.js b/src/index.js index d88033341..d6e05e970 100644 --- a/src/index.js +++ b/src/index.js @@ -31,7 +31,7 @@ function VirtualMachine () { // Blocks switch (e.type) { case 'create': - instance.runtime.createBlock(adapter(e)); + instance.runtime.createBlock(adapter(e), false); break; case 'change': instance.runtime.changeBlock({ @@ -57,6 +57,27 @@ function VirtualMachine () { break; } }; + + instance.flyoutBlockListener = function (e) { + switch (e.type) { + case 'create': + instance.runtime.createBlock(adapter(e), true); + break; + case 'change': + instance.runtime.changeBlock({ + id: e.blockId, + element: e.element, + name: e.name, + value: e.newValue + }); + break; + case 'delete': + instance.runtime.deleteBlock({ + id: e.blockId + }); + break; + } + }; } /**