Count measurement Tool - multiple counters

The count tool (PDFTron WebViewer Class: CountMeasurementCreateTool) uses the same counter for all the 4 “subtools”
Is there a way to desynchronize the tools so that you have one counter per color / tool ?

Thanks

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi Michael,

You can do it with the following code added to your application:

const { annotationManager } = instance.Core
annotationManager.addEventListener('annotationSelected',(annotList, action)=>{
    if (annotList.length === 1 && action ==='selected' && annotList[0].ToolName.includes('AnnotationCreateCountMeasurement')) {
        var overlayEl = ins.docViewer.getViewerElement().closest('#app').getElementsByClassName('measurement__count')[0];
        // Text can be in other languages so need to get this first
        const text = overlayEl.textContent.split(':')[0];
        overlayEl.textContent = `${text}: ${annotationManager.getAnnotationsList().filter(annot=> annot.ToolName === annotList[0].ToolName).length}`
    }
})

Thanks Ychen, will try this!