Check mouse click in script

Hi everybody! I’m using Ignition 8.0. I’m using a script located on the Event Handlers->mouseClicked of a button. Is it possibile to check a mouse click (setting a variable for example) in a client script (timer script)?
This is the code that I have write but “Bit_test” is always set to 0…

window = system.gui.getWindow(“Main Window”)
Bit_test = window.getRootContainer().getComponent(“Text_1”).mouseClicked

Thanks and good work

Hi Gabriele,
could I ask you why you want to catch a click event on a timer script?

Correct me if I miss understood, what you want to achieve is the following :

  • create a tag (client or gateway) storing a bool value, we call the tag Trigger
  • we assume that the value of Trigger is False
  • now when you click a button you need to set the tag Trigger to True
  • at one point your client timer script will fire up, verify if Trigger is True, do some work, then reset the tag.

Is this your aim?

From your post, I personally understood that you want a timer script, continuously running, verify if in that moment a click occurred, but I don’t think it works that way. (I may be wrong, and If I am I will be more than happy to learn something new)
MouseClicked is an event, not a property, so you don’t have access to his state.

The Mouse Clicked Event get triggered by a click, and if you don’t catch it from the Event Handlers->mouseClicked script, you will loose it.
I think the strategy here will be catch the click event, store the information in a tag, and then from your timer script read the value previously stored in your tag and act accordingly.

1 Like

Hi Luca,
yes, all that you have described is what I would like to realize. I would like to put all the code on a timer script fot two reasons:

  • To take out all the code (if it’s possibile) from the designer to be able to modify all component without losing any code (specially for future modify)
  • Write only one script code that can be use with multiple object that are positioned on the page. If I call the object with a specific criterion, I can perform the same action on a lot of component maybe using a FOR cycle (changing only the name of the components)

I think that your advice is good idea, surely I will realize the application using this way, thanks

What do these objectives (writing common code in one place) have to do with timer scripts versus mouse clicks? Both types of events (and all the others) can call script module functions with the common code you wish to maintain.

2 Likes