Get Selected Annotation

Describe Your Question

Scenario: I created multiple measurements using the Length tool. When selecting a created annotation I would like to fire an event and delete the selected annotation.

Question: How can I create a callback for annotation tools that emit an event with the selected annotation. I could not find any information in the documentation.

  • Using Cornerstonejs + Conerstonetools (latest versions)

Hello @joni8a and welcome to the OHIF community and thanks for your question.

If I understand your question correctly, one way to handle deleting the selected annotation is to…

  • Use the annotationSelection module to get the selected tools. There is a function getAnnotationsSelected which might prove useful to you. It returns the UIDs of the selected tools.
  • To remove a tool by UID, use the removeAnnotation function in the annotationState module

I hope this helps. Let me know how it goes.

Joe