Closed nwaelti closed 6 months ago
Thank you for asking!
Internally, this is done by replacing the existing background with a new BackgroundComponent
with the correct grid type. The API for this is much more complicated than it should be, however.
In short,
Erase
the background layerBackgroundComponent
with the correct color and pattern.Some notes:
BackgroundComponent
s.editor.dispatchNoAnnounce(editor.image.setGridEnabled(true), false);
or even editor.dispatchNoAnnounce(BackgroundComponent.setPattern(BackgroundPattern.Grid), false);
would be much easier to use and maintain, as mentioned above.Okay, it is fairly complicated, but at least with your example I can go further with
editor.dispatchNoAnnounce( editor.image.addElement(new BackgroundComponent(BackgroundType.Grid, Color4.white)), );
Thanks a lot for your help ;)
Version 1.7.0 has a simplified API for this. See Editor.setBackgroundStyle.
I can't seem to find a way to turn on the Grid by default or programatically.
I'm using
editor.dispatchNoAnnounce(editor.image.setAutoresizeEnabled(true), false);
in order to set Autoresize, but there is nosetGridEnabled()
Also checking on the BackgroundStyle, I've seen a
getBackgroundStyle
but not a set...Am I completely wrong? When not, it would be nice to have such function, either in the settings like
gridEnabled: true
or with a dispach likeeditor.dispatchNoAnnounce(editor.image.setGridEnabled(true), false);
.Cheers, Nick