Readonly Mode & Tools
These methods control whether the display is editable at all and, when it is, which interaction tool is active.
setReadOnlyMode()
Enables or disables read-only mode for the entire display.
setReadOnlyMode(readOnly: boolean): void;
When read-only mode is active, all editing tools are disabled — the user can only pan, zoom, and select entities. Selecting an entity shows a selection rectangle around it, but no edit nodes are displayed, so the entity cannot be moved, resized, or modified.
Read-only mode is the default in OneVision. The display starts in read-only mode and stays there until you explicitly disable it.
Set readOnly to false to allow full editing — at that point the user can move entities, drag nodes, draw new shapes, and delete elements.
For finer-grained control over which individual tools are visible or enabled, use setGeomConfig() instead (see Geometry Config).
var ctrl = Visu.page0.display1.getController();
// Lock the display — user can only pan and zoom
ctrl.setReadOnlyMode(true);
// Unlock — restore full editing
ctrl.setReadOnlyMode(false);
setTool()
Sets the active interaction tool. The "view" and "select" tools are always available regardless of read-only mode. Editing tools ("draw", "edit", "edit-nodes", "type-text") have no effect when read-only mode is enabled.
setTool(tool: TActiveTool): void;
TActiveTool is a discriminated union. Each tool type has a different shape:
type | Extra fields | Description |
|---|---|---|
"view" | — | Pan and zoom only, no interaction |
"select" | — | Click to select an entity; shows transform box |
"edit-nodes" | — | Click an entity to enter construction-point edit mode |
"edit" | entityId: number | Immediately enters edit mode for a specific entity |
"draw" | shape: TDrawableShape | User draws a new entity of the given shape |
"type-text" | entityId: number | Activates text-entry mode for a string entity |
var ctrl = Visu.page0.display1.getController();
// Switch to view-only mode
ctrl.setTool({ type: "view" });
// Enable selection
ctrl.setTool({ type: "select" });
// Let the user draw a new rectangle
ctrl.setTool({ type: "draw", shape: "rect2d" });
// Enter edit-nodes mode for element with id 42
ctrl.setTool({ type: "edit", entityId: 42 });
TDrawableShape values
"rect2d", "oriented-rect2d", "circle2d", "ellipse2d", "segment2d", "line2d", "point2d", "path2d", "shape2d", "string"
After the user finishes drawing a shape, the tool does not automatically revert to "view" or "select". If you want a one-shot draw behavior, read entityCreated in State Properties and then call setTool({ type: "select" }) to switch back.