# Mouse Click count inside a module

**URL:** <https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791>\
**Category:** Ignition\
**Created:** [March 30, 2022, 7:41am UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791 "2022-03-30T07:41:25Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [March 30, 2022, 7:41am UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791/1 "2022-03-30T07:41:25Z")

</div>

Hi ,

can we able to capture the mouse click count ( **how many times user clicked the mouse inside a module** )

Is it possible to do?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 30, 2022, 8:27am UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791/2 "2022-03-30T08:27:49Z")

</div>

in the onclick event you can get it with  
`event.detail`  
it resets after a delay tho (just like double click does)

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [March 30, 2022, 8:35am UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791/3 "2022-03-30T08:35:11Z")

</div>

Any common gateway script can be written to capture the clicks? because In module where ever user clicks, i want capture and want to store it in database

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 30, 2022, 8:43am UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791/4 "2022-03-30T08:43:18Z")

</div>

> [@prasath.t](#):
>
> gateway

any client onclick event has this, so i guess if you put it on the root it would get all the clicks?  
Why are you trying to store user clicks count tho? xd

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [March 30, 2022, 8:47am UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791/5 "2022-03-30T08:47:15Z")

</div>

Why are you trying to store user clicks count tho?

To know how effective user is using the module. whether they simple open and keeping the module or they using effectively like that

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [March 30, 2022, 8:48am UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791/6 "2022-03-30T08:48:56Z")

</div>

> [@victordcq](#):
>
> event.detail

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/8/58222258c45146d4de92353c06f40dae45ef0c56.png)

I have tired to put like this in root container.  
but getting error

AttributeError: 'java.awt.event.MouseEvent' object has no attribute 'detail'

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 30, 2022, 8:52am UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791/7 "2022-03-30T08:52:05Z")

</div>

Ah its vision… detail if for perspective

for java its this i guess?  
event.getClickCount()  
**[getClickCount](https://docs.oracle.com/javase/7/docs/api/java/awt/event/MouseEvent.html#getClickCount())** ()

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [March 30, 2022, 8:58am UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791/8 "2022-03-30T08:58:04Z")

</div>

> [@victordcq](#):
>
> event.getClickCount()  
> **[getClickCount](https://docs.oracle.com/javase/7/docs/api/java/awt/event/MouseEvent.html#getClickCount())** ()

ya its working but its starts capturing only when we click on root container. when i click any component its not capturing

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 30, 2022, 9:42am UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791/9 "2022-03-30T09:42:49Z")

</div>

I dont know enough about vision to help you sorry.  
maybe @pturmel knows more?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 30, 2022, 11:17am UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791/10 "2022-03-30T11:17:02Z")

</div>

In java Swing, events stop propagating up the tree of components/containers at the component where they are consumed. You will need listeners _ **everywhere** _, including in nested components that are implementation details of Vision components.

I wouldn’t even attempt to do this.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 30, 2022, 2:28pm UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791/11 "2022-03-30T14:28:11Z")

</div>

While I agree with Phil that this is very likely a bad idea, I think _technically_ you could install a global AWTEventListener and capture all mouse clicks across the entire program. Turning those clicks into useful component references would be its own challenge, however.

[https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/java/awt/event/AWTEventListener.html](https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/java/awt/event/AWTEventListener.html)

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [March 30, 2022, 2:42pm UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791/12 "2022-03-30T14:42:34Z")

</div>

Thanks i will check it

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [March 30, 2022, 2:45pm UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791/13 "2022-03-30T14:45:52Z")

</div>

In which place we to use the global listener… In gateway script?

Any example can you able to give please

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 30, 2022, 3:10pm UTC](https://forum.inductiveautomation.com/t/mouse-click-count-inside-a-module/57791/14 "2022-03-30T15:10:34Z")

</div>

Probably a client startup script. You would get an instance of the Toolkit, then register your event listener (filtering for mouse events, most likely):  
[https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/java/awt/Toolkit.html#addAWTEventListener(java.awt.event.AWTEventListener,long)](https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/java/awt/Toolkit.html#addAWTEventListener(java.awt.event.AWTEventListener,long))

Forwarding events to the gateway and collecting them is an exercise for the reader.
