Perspective Navigation with OnClick Button(s)

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

On State(onClick):
image

Create your Navigation and give it a text value of your choice, as shown below:
image

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!

You can simplify your onClick script:

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.

2 Likes