Update README.md with new block change listener calls

This commit is contained in:
Tim Mickel 2016-06-08 17:30:22 -04:00
parent 58db14ac0e
commit 20cb88c066

View file

@ -16,16 +16,9 @@ var VirtualMachine = require('scratch-vm');
var vm = new VirtualMachine(); var vm = new VirtualMachine();
// Block events // Block events
workspace.addChangeListener(function(e) { workspace.addChangeListener(vm.blockListener);
// Handle "tapping" a block var flyoutWorkspace = workspace.toolbox_.flyout_.workspace_;
if (e instanceof Blockly.Events.Ui && e.element === 'click') { flyoutWorkspace.addChangeListener(vm.flyoutBlockListener);
var stackBlock = workspace.getBlockById(e.blockId).getRootBlock().id;
vm.runtime.toggleStack(stackBlock);
// Otherwise, pass along to the block listener
} else {
vm.blockListener(e);
}
});
// Run threads // Run threads
vm.runtime.start(); vm.runtime.start();