# Trigger 'mouseMove' and 'click' event while drawing an annotation

**URL:** <https://pdfjs.community/t/trigger-mousemove-and-click-event-while-drawing-an-annotation/93>\
**Category:** Technical Support\
**Created:** [June 26, 2020, 4:18am UTC](https://pdfjs.community/t/trigger-mousemove-and-click-event-while-drawing-an-annotation/93 "2020-06-26T04:18:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vivek.sonawane](https://avatars.discourse-cdn.com/v4/letter/v/e95f7d/32.png) [@vivek.sonawane](https://pdfjs.community/u/vivek.sonawane)\
**Post date:** [June 26, 2020, 4:18am UTC](https://pdfjs.community/t/trigger-mousemove-and-click-event-while-drawing-an-annotation/93/1 "2020-06-26T04:18:05Z")

</div>

Hi,

We are trying to get area value of an annotation while drawing it. While drawing, on every single click we want to fetch area of that annotation.  
For now when we complete drawing the annotation, on double click we are getting area.  
Could you please tell us how we can trigger click event while drawing an annotation so we can  
get area at every point.

Thank you.

---

<div class="post-metadata">

**Author:** ![zzhang](https://avatars.discourse-cdn.com/v4/letter/z/b9e5f3/32.png) [@zzhang](https://pdfjs.community/u/zzhang)\
**Post date:** [June 26, 2020, 7:00pm UTC](https://pdfjs.community/t/trigger-mousemove-and-click-event-while-drawing-an-annotation/93/2 "2020-06-26T19:00:30Z")

</div>

Hi,

It sounds like you are wanting to get the area of a polygon annotation when users are drawing it.

To do this, you can listen to the [mouseMove](https://pdfjs.express/api/CoreControls.DocumentViewer.html#event:mouseMove__anchor) event of **docViewer**. Then inside the event callback you can use [docViewer.getToolMode](https://pdfjs.express/api/CoreControls.DocumentViewer.html#getToolMode__anchor) to get the current tool. Once you have checked the current tool is the polygon tool, you can access the drawing annotation by `tool.annotation`. Now since you have the `annotation` object you can use [getPath](https://pdfjs.express/api/Annotations.PolygonAnnotation.html#getPath__anchor) and do calculations to get the area.

Best Regards,  
Zhijie Zhang

---

<div class="post-metadata">

**Author:** ![zzhang](https://avatars.discourse-cdn.com/v4/letter/z/b9e5f3/32.png) [@zzhang](https://pdfjs.community/u/zzhang)\
**Post date:** [July 13, 2020, 5:21pm UTC](https://pdfjs.community/t/trigger-mousemove-and-click-event-while-drawing-an-annotation/93/3 "2020-07-13T17:21:33Z")

</div>


