# Perspective Navigation with OnClick Button(s)

**URL:** <https://forum.inductiveautomation.com/t/perspective-navigation-with-onclick-button-s/74309>\
**Category:** Ignition\
**Tags:** ignition81, perspective, scripting, python\
**Created:** [May 30, 2023, 5:26pm UTC](https://forum.inductiveautomation.com/t/perspective-navigation-with-onclick-button-s/74309 "2023-05-30T17:26:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yash\_Patel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yash_patel/32/45025_2.png) [@Yash\_Patel](https://forum.inductiveautomation.com/u/Yash_Patel)\
**Post date:** [May 30, 2023, 5:26pm UTC](https://forum.inductiveautomation.com/t/perspective-navigation-with-onclick-button-s/74309/1 "2023-05-30T17:26:40Z")

</div>

If you want onClick button(s) on the Navigation menu, you can do it within Ignition using Ignition event script.

Working Example:  
Off State:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/3/63750fdade23429e71e863b1d41e0b1b12945196.png)

On State(onClick):  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/6/262cf61e83d1d0f49aceb6618fcc46a4c41e9cb5.png)

Create your Navigation and give it a text value of your choice, as shown below:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/4/f4abe72a282cde2a5dbfcd642ac1ec23ef9d680a.png)

Now, I have "Turn On" and "Turn Off" state for my original button(You can add more states if you like!)

1. Create a script that looks for the label from the Nav menu(Make sure to double check the actual Tag value that you want to set onClick):  

2. Bind the tag value to the text, and give it a opposite map values so it can be changed again(ex. If 1=T and 0=F, here use 1=F and 0=T so text can be changed on next click):  

3. I have a little turn on/off indicator that I wanted to show on my Nav to display its status.  

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:** [May 30, 2023, 6:14pm UTC](https://forum.inductiveautomation.com/t/perspective-navigation-with-onclick-button-s/74309/2 "2023-05-30T18:14:55Z")

</div>

You can simplify your onClick script:

```auto
if event.path[0] == 6: # you actually don't care about the text - only the path
    tag_path = "[default]test 1"
    # always negate the boolean tag
    system.tag.writeBlocking(tag_path, not system.tag.readblocking(tag_path).value)

```

Also, when binding the text of the item or the path of the icon, you might want to supply a text value of "Unknown State For Tag" in the Map (text) or an error state icon path for the path, lest you supply "Turn On" as the text in instances where the Tag is faulted. In this scenario, it might also be helpful to bind the `enabled` property for this item against the quality of the tag.
