How can I prevent a "quick" mouse click

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.

You can retrieve the current time with 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:

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

Then in mouseReleased:

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

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, but I didn’t found the description of these functions.
Please can send link where the functions are described.

These are core methods of Java Swing JComponents. Java Swing is the basis for Ignition’s GUI.

2 Likes

Phil, thanks so much!

That worked great.

Thank you. :slight_smile: