mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-05-06 19:40:58 -04:00
Update README.md with new block change listener calls
This commit is contained in:
parent
58db14ac0e
commit
20cb88c066
1 changed files with 3 additions and 10 deletions
13
README.md
13
README.md
|
@ -16,16 +16,9 @@ var VirtualMachine = require('scratch-vm');
|
|||
var vm = new VirtualMachine();
|
||||
|
||||
// Block events
|
||||
workspace.addChangeListener(function(e) {
|
||||
// Handle "tapping" a block
|
||||
if (e instanceof Blockly.Events.Ui && e.element === 'click') {
|
||||
var stackBlock = workspace.getBlockById(e.blockId).getRootBlock().id;
|
||||
vm.runtime.toggleStack(stackBlock);
|
||||
// Otherwise, pass along to the block listener
|
||||
} else {
|
||||
vm.blockListener(e);
|
||||
}
|
||||
});
|
||||
workspace.addChangeListener(vm.blockListener);
|
||||
var flyoutWorkspace = workspace.toolbox_.flyout_.workspace_;
|
||||
flyoutWorkspace.addChangeListener(vm.flyoutBlockListener);
|
||||
|
||||
// Run threads
|
||||
vm.runtime.start();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue