Lock a dizmo and make it sticky

As described in the chapter Hierarchies, the user can arrange dizmos in hierarchies and in a spatial order. In order not to lose this particular spatial order, the user can make a dizmo sticky in the dizmo settings. If the user wishes to not accidentally modify the dizmo, they can lock the dizmo in the dizmo settings.

Lock a dizmo

Lock a dizmo
Lock a dizmo

When a dizmo is locked, it can not be dragged around and it can not be modified by the user. As illustrated in the picture below, the settings only show that the dizmo is locked. Only when the user unlocks the dizmo (that is, click on "Lock" the only available item in settings), can they access the other items in settings and modify the dizmo again.

Locked dizmo
Locked dizmo

You can set your dizmo to locked:

dizmo.setAttribute('state/locked', true);

Make a dizmo sticky

Sticky
Sticky

Once a dizmo is sticky, it always keeps it position relative to the four corners of dizmoViewer. Even if the user zooms out of dizmoViewer, drags it around or resizes it, the sticky dizmo always remains in the same spot.

You can provision that your dizmo is set to sticky flag, so that it always remains on the spot by using

dizmo.setAttribute('state/sticky', true);

Remember that you have to make provisions for the geometry, when a dizmo is sticky:

dizmo.setAttribute("stickyGeometry/angle", value);
dizmo.setAttribute("stickyGeometry/x", value);
dizmo.setAttribute("stickyGeometry/y", value);

When resizing the dizmoViewer window, a sticky dizmo remembers which edge it is bordering: true if the sticky position of the dizmo is relative to left, otherwise to right; respectively true if the sticky position of the dizmo is relative to top, otherwise bottom.

dizmo.getAttribute("stickyGeometry/left");
dizmo.getAttribute("stickyGeometry/top");

These attributes can only be read.