Changing the grid layout

114 views
Skip to first unread message

Magnet

unread,
Mar 1, 2017, 7:14:31 AM3/1/17
to Blockly
I made a slider so the user can choose the preferred grid spacing. I was able to get the grid functioning very well but the dots drawed on screen wont change accordingly. I figured out where the values are saved and changed those. That did spread out the dots but the snapping wont match with setting the workspace up with this spacing.

Here is the code I wrote:
workspace.spacing = newSpacing;
workspace
.options.gridOptions.spacing = newSpacing;
workspace
.options.gridPattern.width.baseVal.value = newSpacing;
workspace
.options.gridPattern.height.baseVal.value = newSpacing;


Is there a better way or a function I missed to do this?


Magnet

Rachel Fenichel

unread,
Mar 1, 2017, 12:34:02 PM3/1/17
to Blockly
The grid is set up at injection and isn't designed to be changed afterwards.  You'll have to reinject your Blockly instance.  Check out the workspace factory code for an example.



Cheers,
Rachel

--
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