Hey there!
This one is a bit tricky just because of the timing of how all that works.
Basically the final point of the annotation is added after the double click event, so we can listen for any annotations that get added right after a double click, and then delete it.
This code should do what you want:
const { docViewer, Tools, annotManager } = instance;
const perimeterTool = docViewer.getTool(Tools.ToolNames.PERIMETER_MEASUREMENT);
docViewer.on('dblClick', () => {
const perimeterAddedHandler = (annotation) => {
annotation.getPath().pop();
annotation.adjustRect();
annotManager.redrawAnnotation(annotation);
perimeterTool.off('annotationAdded', perimeterAddedHandler);
};
perimeterTool.on('annotationAdded', perimeterAddedHandler);
setTimeout(() => {
// if no perimeter annotation is added just after the double click
// then it must not have added an annotation so we can remove the handler
perimeterTool.off('annotationAdded', perimeterAddedHandler);
}, 100);
});
Basically this just checks if there was an annotation added shortly after double clicking, and it removes the last point from it if there was.
I hope this helps!
Thanks,
Logan