# How can I prevent a "quick" mouse click

**URL:** <https://forum.inductiveautomation.com/t/how-can-i-prevent-a-quick-mouse-click/21002>\
**Category:** Ignition\
**Created:** [November 21, 2018, 8:19pm UTC](https://forum.inductiveautomation.com/t/how-can-i-prevent-a-quick-mouse-click/21002 "2018-11-21T20:19:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsteward](https://avatars.discourse-cdn.com/v4/letter/j/8e7dd6/32.png) [@jsteward](https://forum.inductiveautomation.com/u/jsteward)\
**Post date:** [November 21, 2018, 8:19pm UTC](https://forum.inductiveautomation.com/t/how-can-i-prevent-a-quick-mouse-click/21002/1 "2018-11-21T20:19:21Z")

</div>

I’m designing for a touch screen and want to use the mouse pressed and mouse released events. I only want the event scripts to run if the mouse has been pressed for at least 250 ms. Is there a way to count the time a mouse button has been held down? Also, how can I pass a variable from the mousePressed event to the the mouseRelease event.

thanks for any help.

---

<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:** [November 21, 2018, 8:49pm UTC](https://forum.inductiveautomation.com/t/how-can-i-prevent-a-quick-mouse-click/21002/2 "2018-11-21T20:49:39Z")

</div>

You can retrieve the current time with [system.date.now()](https://docs.inductiveautomation.com/display/DOC79/system.date.now) in mousePressed and place it in a client property, then retrieve that in mouseReleased to check the duration. Something like this, mousePressed:

```auto
event.source.putClientProperty('pressTS', system.date.now())

```

Then in mouseReleased:

```auto
pressTS = event.source.getClientProperty('pressTS')
if pressTS and (system.date.now().time - pressTS.time) > 250:
   # do something

```

---

<div class="post-metadata">

**Author:** ![mpeteri](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@mpeteri](https://forum.inductiveautomation.com/u/mpeteri)\
**Post date:** [November 22, 2018, 7:14pm UTC](https://forum.inductiveautomation.com/t/how-can-i-prevent-a-quick-mouse-click/21002/3 "2018-11-22T19:14:48Z")

</div>

Hello, it is interesting, and I think useful. I am beginner for the scripting. I try to found in some more information about functions putClientProperty and getClientProperty on webpage [docs.inductiveautomation.com](http://docs.inductiveautomation.com), but I didn’t found the description of these functions.  
Please can send link where the functions are described.

---

<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:** [November 23, 2018, 1:27am UTC](https://forum.inductiveautomation.com/t/how-can-i-prevent-a-quick-mouse-click/21002/4 "2018-11-23T01:27:17Z")

</div>

These are core methods of Java Swing [JComponents](https://docs.oracle.com/javase/8/docs/api/javax/swing/JComponent.html). Java Swing is the basis for Ignition’s GUI.

---

<div class="post-metadata">

**Author:** ![jsteward](https://avatars.discourse-cdn.com/v4/letter/j/8e7dd6/32.png) [@jsteward](https://forum.inductiveautomation.com/u/jsteward)\
**Post date:** [November 26, 2018, 4:04pm UTC](https://forum.inductiveautomation.com/t/how-can-i-prevent-a-quick-mouse-click/21002/5 "2018-11-26T16:04:58Z")

</div>

Phil, thanks so much!

That worked great.

---

<div class="post-metadata">

**Author:** ![mpeteri](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@mpeteri](https://forum.inductiveautomation.com/u/mpeteri)\
**Post date:** [November 29, 2018, 9:06am UTC](https://forum.inductiveautomation.com/t/how-can-i-prevent-a-quick-mouse-click/21002/6 "2018-11-29T09:06:19Z")

</div>

Thank you. 🙂
