# Perspective Checkbox fires onClick script twice

**URL:** <https://forum.inductiveautomation.com/t/perspective-checkbox-fires-onclick-script-twice/43585>\
**Category:** Ignition\
**Created:** [February 18, 2021, 6:30pm UTC](https://forum.inductiveautomation.com/t/perspective-checkbox-fires-onclick-script-twice/43585 "2021-02-18T18:30:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkylep](https://avatars.discourse-cdn.com/v4/letter/d/6de8d8/32.png) [@dkylep](https://forum.inductiveautomation.com/u/dkylep)\
**Post date:** [February 18, 2021, 6:30pm UTC](https://forum.inductiveautomation.com/t/perspective-checkbox-fires-onclick-script-twice/43585/1 "2021-02-18T18:30:38Z")

</div>

Ignition Perspective  
8.1.1 (b2020120808)  
Checkbox firing ‘onClick’ script, twice…

I ran into this problem and to confirm I made a simple perspective view with 1 Checkbox and 1 Label which has the same behavior.

I set the label’s prop.text = 1

I then added an onClick script to the Checkbox

```auto
	if self.props.selected:
		self.getSibling("Label").props.text += self.getSibling("Label").props.text
		system.perspective.print("select")
	else:
		self.getSibling("Label").props.text -= self.getSibling("Label").props.text
		system.perspective.print("de-select")

```

When I click on the checkbox to set **`props.selected = True`** the labels text changes to 4! Which means it did 1+1=2 and then fired again to do 2+2=4.

If I click the Checkbox again the label’s text changes to 0.

This is what the console reads when clicking the checkbox once to select it and a second time to de-select it

```auto
13:23:35.988 [Browser Thread: 57052] INFO Perspective.Designer.Workspace - select
13:23:35.989 [Browser Thread: 57052] INFO Perspective.Designer.Workspace - select
13:23:37.138 [Browser Thread: 57052] INFO Perspective.Designer.Workspace - de-select
13:23:37.138 [Browser Thread: 57052] INFO Perspective.Designer.Workspace - de-select

```

I can’t figure out why it is firing twice. I don’t recall this issue occurring in an early version of 8.0. I’m digging up an old project and an existing view, that I believe was working previously, now seems to fire twice causing an issue.

Thanks

---

<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:** [February 18, 2021, 7:11pm UTC](https://forum.inductiveautomation.com/t/perspective-checkbox-fires-onclick-script-twice/43585/2 "2021-02-18T19:11:05Z")

</div>

I’m seeing this too, and am unsure of when it was introduced. It appears that onActionPerformed is working correctly, and I always recommend using that event anyway.

Update: It was introduced in our theming update as part of 8.0.13.

---

<div class="post-metadata">

**Author:** ![dkylep](https://avatars.discourse-cdn.com/v4/letter/d/6de8d8/32.png) [@dkylep](https://forum.inductiveautomation.com/u/dkylep)\
**Post date:** [February 18, 2021, 8:17pm UTC](https://forum.inductiveautomation.com/t/perspective-checkbox-fires-onclick-script-twice/43585/3 "2021-02-18T20:17:48Z")

</div>

Thanks, I can modify my checkboxes to utilize the onActionPerformed event instead.

Is there a reason you recommend the onAcitonPerformed over the onClick?

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [February 18, 2021, 8:21pm UTC](https://forum.inductiveautomation.com/t/perspective-checkbox-fires-onclick-script-twice/43585/4 "2021-02-18T20:21:24Z")

</div>

> [@dkylep](#):
>
> Is there a reason you recommend the onAcitonPerformed over the onClick?

Primary reason for me is onClick ALWAYS fires when the control is clicked on, onActionPerformed only fires if the control is enabled.

---

<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:** [February 18, 2021, 8:32pm UTC](https://forum.inductiveautomation.com/t/perspective-checkbox-fires-onclick-script-twice/43585/5 "2021-02-18T20:32:23Z")

</div>

As @MMaynard said: The onClick Event will “fire” even if the checkbox is disabled, whereas the onActionPerformed Event allows for you to disable the component based on potential security requirements. So if a user does not have the required security considerations, and the component is disabled due to this, then the script will not execute even when the component is clicked on.
