# \[Perspective\] Event action script delay

**URL:** <https://forum.inductiveautomation.com/t/perspective-event-action-script-delay/83297>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [December 19, 2023, 7:09am UTC](https://forum.inductiveautomation.com/t/perspective-event-action-script-delay/83297 "2023-12-19T07:09:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![keari0913](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@keari0913](https://forum.inductiveautomation.com/u/keari0913)\
**Post date:** [December 19, 2023, 7:09am UTC](https://forum.inductiveautomation.com/t/perspective-event-action-script-delay/83297/1 "2023-12-19T07:09:16Z")

</div>

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:**

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

````

Am I doing something wrong here?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 19, 2023, 12:53pm UTC](https://forum.inductiveautomation.com/t/perspective-event-action-script-delay/83297/2 "2023-12-19T12:53:42Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [December 19, 2023, 4:52pm UTC](https://forum.inductiveautomation.com/t/perspective-event-action-script-delay/83297/3 "2023-12-19T16:52:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![keari0913](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@keari0913](https://forum.inductiveautomation.com/u/keari0913)\
**Post date:** [December 19, 2023, 8:57pm UTC](https://forum.inductiveautomation.com/t/perspective-event-action-script-delay/83297/5 "2023-12-19T20:57:41Z")

</div>

@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.

```auto
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:**

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/b/cb7b20e8f1292234dccdcfa07b670ac93fcf3d04.png)

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [December 20, 2023, 4:34am UTC](https://forum.inductiveautomation.com/t/perspective-event-action-script-delay/83297/6 "2023-12-20T04:34:54Z")

</div>

I _highly_ advise against using the **same** styling effect to convey _ **multiple** _ meanings.

---

<div class="post-metadata">

**Author:** ![keari0913](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@keari0913](https://forum.inductiveautomation.com/u/keari0913)\
**Post date:** [December 20, 2023, 5:46pm UTC](https://forum.inductiveautomation.com/t/perspective-event-action-script-delay/83297/7 "2023-12-20T17:46:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [December 20, 2023, 7:37pm UTC](https://forum.inductiveautomation.com/t/perspective-event-action-script-delay/83297/8 "2023-12-20T19:37:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![keari0913](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@keari0913](https://forum.inductiveautomation.com/u/keari0913)\
**Post date:** [December 20, 2023, 8:12pm UTC](https://forum.inductiveautomation.com/t/perspective-event-action-script-delay/83297/9 "2023-12-20T20:12:50Z")

</div>

Understood, thank you.
