I have several components with two event action scripts configured each, one onPointerEnter & one onPointerLeave. I would like for the Enter script to only run after the pointer has been over that component for at least a second. Then the Leave script to only run if the Enter has run. This way the scripts aren't running for every single component every time I swipe the cursors across the screen and over the component.
onPointerEnter Script:
import time
time.sleep(1)
id = self.view.params.name
system.perspective.sendMessage('highlight-off', {'exclude': id})
control = self.view.custom.UI
control.highlight = True
control.search = False```
**onPointerLeave Script:**
control = self.view.custom.UI
control.highlight = False ```
Scripts run in the gateway. Mouse events start in the browser. You've already paid the penalty of excess browser traffic by even having a mouse event. And the gateway won't be told that a second has passed with the mouse still there--you have to infer it by the absence of the leave event.
And please include what your end-goal truly is here. Perhaps there's a way to manage what you're doing with pure CSS, removing the need for any scripting.
@cmallonee
To change the style class of components so the border/stroke color of objects change from black to a highlighter green when hovering over. I am aware that this can be done through style class element states. Problem is that it will only work on the component I am hovering over. This seems like the only way to be able to highlight multiple components at the same time by using a message handler. Another thing is that I have a another style class for when a component has an alarm & is being hovered over at the same time. Don't see a way to do this without the event action scripts.
def onMessageReceived(self, payload):
id = self.view.params.name
control = self.view.custom.UI
exclude_id = payload['exclude']
if not id == exclude_id:
control.highlight = False
else:
control.highlight = True
Here is one of the components that has the event action script: