MousePressed and MouseReleased component script

Sorry, no.

  • Resetting a bit in the PLC after set by Ignition has odd race conditions when using an OPC tag. If you use a "fire-and-forget" scripted OPC write (via system.opc.write* instead of via a tag), then it isn't so bad.

  • With that tag event, you can get the set and release so close that the PLC scan doesn't see it.

If you cannot use a reliable protocol, the best option is to use a short integer instead of a boolean. Use a timer in the PLC to make a pulse when the integer changes, and keep the pulse on if the integer keeps changing. Send repeating messages from the client as long as the button is pressed that increment the integer. There's no good way to do this in Perspective, unfortunately. Such a button can be created in Vision. I recommend a PLC rung like this one:


I recommend sending a "1" to PBTrigger when the button is first pressed, then incrementing at a 100ms pace, then sending a "0" when the button is released to cut off without waiting for the timeout. The increment logic needs to skip 0.

In that logic, PBPulse.DB is to be used in the PLC instead of the original pushbutton boolean tag.