How can I tell if a block has been added to or removed from the workspace?

637 views
Skip to first unread message

Jayod

unread,
Apr 20, 2014, 6:26:23 PM4/20/14
to blo...@googlegroups.com
I want to detect if the blocks in the main workspace have changed - if a connection has been made or removed, if a block has been added, or deleted.  Is there an easy way to do this with Blockly?

Scott Haynes

unread,
May 13, 2014, 3:41:55 PM5/13/14
to blo...@googlegroups.com
I'm using 
Blockly.addChangeListener( function( event ) { } );

rajni patel

unread,
Jun 27, 2016, 9:44:54 AM6/27/16
to Blockly
Where to use this ??

Neil Fraser

unread,
Jun 27, 2016, 7:39:54 PM6/27/16
to blo...@googlegroups.com
The thread you replied to is two years old.  This call is now deprecated (though still works).  The preferred method is to call:

workspace.addChangeListener(function( event ) { } )

When you inject Blockly onto the page it returns a workspace object, that's a good time to add the change listener.

To see the events you have access to, go to the playground, open your JavaScript console, and drag some blocks around.


--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages