Readonly Options

289 views
Skip to first unread message

sha...@techykids.com

unread,
Jan 11, 2017, 5:33:56 PM1/11/17
to Blockly
Hi,
1) I'd like it possible that when Blockly is in Readonly mode that you can click on the block and it will open up a webpage.  Or enable the right click menu to access the Help Menu that would open up a webpage. 

2) How can you toggle the blockly map from readonly to edittable from the front end?

Thanks a bunch for your help in the matter!

Neil Fraser

unread,
Jan 11, 2017, 11:58:01 PM1/11/17
to blo...@googlegroups.com
On 11 January 2017 at 14:33, <sha...@techykids.com> wrote:
1) I'd like it possible that when Blockly is in Readonly mode that you can click on the block and it will open up a webpage.  Or enable the right click menu to access the Help Menu that would open up a webpage. 

Out of the box, no that's not a supported feature.  However, it sounds pretty easy for any JavaScript developer to add.  That said, your second point should be addressed first since it affects this one significantly.
 
2) How can you toggle the blockly map from readonly to edittable from the front end?

Toggling from readonly to editable would be very difficult.  A bunch of event handlers would need to be added or removed, and any attempt to do this would be a continuing source of bugs going forward.  There are three more feasible options which might result in similar functionality:
1) Save the workspace as XML, destroy Blockly, create a new Blockly in the new mode (readonly or not), restore the workspace.  This will allow one to change the readonly mode, but the transition won't be seamless since scrollbar positioning (amongst other smaller UI issues) will jump.
2) Place a transparent div on top of Blockly so that all mouse/touch interactions are squelched.  Also deselect any selected block, so that delete doesn't work.  You'd also need to look at how to squelch keyboard paste.  This option would not allow scrolling the readonly version or any other interactions (including the previously asked ability to open a web page when clicking on a block).
3) Loop through all blocks on the workspace and toggle each one's movable, deletable, and editable properties.  Additional work would be needed to update the toolbox XML so that all blocks in it are (or are not) disabled.  Also look at keyboard paste.

Each of these three options should be quite feasible.

--
Reply all
Reply to author
Forward
0 new messages