Select Measurement
Listen for active selection changes and control the selected measurement from the host application.
Selection in the viewer works in both directions. The viewer emits `annotationSelected` when a user clicks an existing measurement or annotation, and the host can request a specific selection with `selectAnnotation`.
This is the main entry point for actions such as opening a properties panel, enabling delete controls, or syncing a sidebar row with the active canvas item.
- Viewer Event: `annotationSelected` is emitted after a measurement becomes active.
- Host Command: `selectAnnotation` selects a known annotation by GUID.
- Clear Command: `unselectAnnotation` clears the active selection.
Most integrations need three simple pieces: listen for selection changes, select an item by GUID when needed, and clear the selection when the workflow ends.
Listen for annotationSelected
Select by GUID
Clear active selection
When the user clicks a measurement on the canvas, the viewer becomes the source of truth and returns the selected annotation payload to the host.
The click itself happens inside the viewer UI, so the code starts at the first emitted message rather than the physical canvas interaction.
1. Viewer emits annotationSelected
The viewer sends the active GUID and annotation data back to the host.
2. Host syncs UI
The host uses the GUID and payload to highlight the matching row, open tools, or enable follow-up actions.
Use `selectAnnotation` when the host already knows the target GUID and needs the viewer to focus that item.
Use `unselectAnnotation` to clear the current selection before switching context or closing a selection-driven workflow.
1. Host sends selectAnnotation
The host asks the viewer to activate a specific annotation by GUID.
2. Viewer returns annotationSelected
After selection is applied, the viewer emits the same selection event used for manual clicks.
3. Host clears selection with unselectAnnotation
The host clears the active annotation when the selection is no longer needed.
Select and clear from the host
The `annotationSelected` payload contains the selected GUID plus the annotation metadata returned by the viewer.
A common integration pattern is to listen for `annotationSelected`, keep the active GUID in host state, and expose helper functions that can select or clear measurements on demand.
Continue with related measurement workflows and API references.
- Delete: Delete Measurement
- Save: Save Measurements
- Clear: Clear Canvas
- Technical: API Reference
