# Change background color back and forth on mouse click

**URL:** <https://forum.inductiveautomation.com/t/change-background-color-back-and-forth-on-mouse-click/28088>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [September 7, 2019, 3:22am UTC](https://forum.inductiveautomation.com/t/change-background-color-back-and-forth-on-mouse-click/28088 "2019-09-07T03:22:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpavlicek](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rpavlicek/32/55868_2.png) [@rpavlicek](https://forum.inductiveautomation.com/u/rpavlicek)\
**Post date:** [September 7, 2019, 3:22am UTC](https://forum.inductiveautomation.com/t/change-background-color-back-and-forth-on-mouse-click/28088/1 "2019-09-07T03:22:53Z")

</div>

This should be fairly simple, but I’m wanting to change the background color of a numeric label back and forth when clicking on it. Basically a select, deselect, so when I select it, the background will change to one color from the original, and if I want to deselect it, I would click on it again so it changes back. Here’s my code on the component scripting which uses and if / elif statement, but it’s not working.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/4/4d9f517dc5f40bb8d372819e5ad0f3249449bffe.png)

---

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [September 7, 2019, 7:15am UTC](https://forum.inductiveautomation.com/t/change-background-color-back-and-forth-on-mouse-click/28088/2 "2019-09-07T07:15:17Z")

</div>

You need to assign a color object to the background property ([system.gui.color](https://docs.inductiveautomation.com/display/DOC80/system.gui.color)).  
Also comparing a color object for equality may fail, try using a custom property as a toggle bit instead.

---

<div class="post-metadata">

**Author:** ![rpavlicek](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rpavlicek/32/55868_2.png) [@rpavlicek](https://forum.inductiveautomation.com/u/rpavlicek)\
**Post date:** [September 7, 2019, 2:34pm UTC](https://forum.inductiveautomation.com/t/change-background-color-back-and-forth-on-mouse-click/28088/3 "2019-09-07T14:34:11Z")

</div>

Thank you, this solved it. I simply added system.gui.color, so it made it system.gui.color(255,255,255).
