[Perspective] Event action script delay

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
	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	```

Am I doing something wrong here?

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.

Why do you need this?

1 Like

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.


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
		control.highlight = True

Here is one of the components that has the event action script:

I highly advise against using the same styling effect to convey multiple meanings.

1 Like

Pardon me, I think I'm misunderstanding you. Every style I'm using has a different meaning.

The way I have it:

  • Stroke is black when device is not faulted and not being hovered over.

  • Stroke is highlighter green when device is not faulted but is being hovered over.

-Stroke flashes between black & red when an alarm or fault is present.

-Stroke flashes between black & highlighter green when an alarm or fault is present on device & it's being hovered over with cursor on the screen.

You're using stroke to convey BOTH hover AND alarm state. This is a bad idea.

1 Like

Understood, thank you.