mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-05-15 07:51:04 -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();
|
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();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue