# Navigation with Perspective Tree: onSelect event not firing

**URL:** <https://forum.inductiveautomation.com/t/navigation-with-perspective-tree-onselect-event-not-firing/55001>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 13, 2022, 9:22pm UTC](https://forum.inductiveautomation.com/t/navigation-with-perspective-tree-onselect-event-not-firing/55001 "2022-01-13T21:22:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mason\_Taylor](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Mason\_Taylor](https://forum.inductiveautomation.com/u/Mason_Taylor)\
**Post date:** [January 13, 2022, 9:22pm UTC](https://forum.inductiveautomation.com/t/navigation-with-perspective-tree-onselect-event-not-firing/55001/1 "2022-01-13T21:22:42Z")

</div>

I am trying to create a tree component that will be used to navigate to different pdfs stored on one of our servers. The goal was that users can expand the topics of interests and then click on a specific page to open the pdf in a new tab. It would work much like the navigation menu for the ignition docs. Essentially the equivalent of [Vision Tree Navigation](https://docs.inductiveautomation.com/display/DOC81/Navigation+-+Tree+View) but in perspective. I am trying to use the onSelect event of the tree, but it never executes.

I am open to other ideas of how to get this working, but I really feel like the onSelect event should be the way to do it. Any ideas why it would not fire?

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:** [January 14, 2022, 2:37am UTC](https://forum.inductiveautomation.com/t/navigation-with-perspective-tree-onselect-event-not-firing/55001/2 "2022-01-14T02:37:36Z")

</div>

You should be using the `onItemClicked` Event.

---

<div class="post-metadata">

**Author:** ![Mason\_Taylor](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Mason\_Taylor](https://forum.inductiveautomation.com/u/Mason_Taylor)\
**Post date:** [January 14, 2022, 3:11am UTC](https://forum.inductiveautomation.com/t/navigation-with-perspective-tree-onselect-event-not-firing/55001/3 "2022-01-14T03:11:43Z")

</div>

I did try that, however, in the event handler I couldn’t get which item was clicked/selected since the `selectionData` property doesn’t update before the event handler runs. I ended up trying `onDoubleClick`, which worked in the way I had hoped either `onItemClicked` or `onSelect` would. It’s a bit odd to have to double click on links on a website, but I think users can get used to it, so it will work.  
For my future reference though, I wonder if you know:

1. What is the `onSelect` event for, and when does it occur?
2. Is there a way to delay event handlers in order to allow properties to update/avoid race conditions? I tried adding a script before my navigation command, but the navigation did not wait for the script to complete.

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:** [January 14, 2022, 4:32am UTC](https://forum.inductiveautomation.com/t/navigation-with-perspective-tree-onselect-event-not-firing/55001/4 "2022-01-14T04:32:17Z")

</div>

You don’t need the `selectionData` content, because all of that is available within the `event` object available within the Script Action. The `selection` and `selectionData` properties are just pieces of the back-end event being made visible to the front-end so that you could bind other properties to them instead of requiring you to write custom logic to set properties.

```auto
def runAction(self, event):
	"""
	Fired whenever an item is clicked on this tree.

	Arguments:
		self: A reference to the component that is invoking this function.
		event: An object with the following attributes:
			data: The value of the contextual 'data' object on the clicked node
			itemPath (list): A list containing the item indexes leading to the item
			                 that was clicked.
			label (str): Text to display for this option.
	"""
	system.perspective.print(str(event))

```

This will give you a break-down of the shape you can expect for a given option.

---

<div class="post-metadata">

**Author:** ![Mason\_Taylor](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Mason\_Taylor](https://forum.inductiveautomation.com/u/Mason_Taylor)\
**Post date:** [January 14, 2022, 4:43am UTC](https://forum.inductiveautomation.com/t/navigation-with-perspective-tree-onselect-event-not-firing/55001/5 "2022-01-14T04:43:06Z")

</div>

That could work, but how can I get that event information into a Navigation action? I have the URL for every tree item embedded in it’s data, and I can see that is accessible from a Script action, but I don’t know how to access that from the Navigation action. Is there a way to pass data from the Script action to the Navigation action to set the URL?

That’s why I was trying to use selectionData since that is only property I can find available to bind to the URL in the Navigation action, like this:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/a/8a8cfaca0cc145dd83b60bd91f363987c90b4c53.png)

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [January 14, 2022, 4:45am UTC](https://forum.inductiveautomation.com/t/navigation-with-perspective-tree-onselect-event-not-firing/55001/6 "2022-01-14T04:45:49Z")

</div>

just add more lines to the script (that same script) and use  
[system.perspective.navigate()](https://docs.inductiveautomation.com/display/DOC81/system.perspective.navigate)

---

<div class="post-metadata">

**Author:** ![Mason\_Taylor](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Mason\_Taylor](https://forum.inductiveautomation.com/u/Mason_Taylor)\
**Post date:** [January 14, 2022, 4:48am UTC](https://forum.inductiveautomation.com/t/navigation-with-perspective-tree-onselect-event-not-firing/55001/7 "2022-01-14T04:48:56Z")

</div>

That could work as well, if the navigate function had an option for opening a new tab (users of my app demand that docs always open in a new tab). Last I checked on the documentation and forums, that was not an option. Please let me know if that is possible, as that would be very useful for other areas of navigation on my app.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [January 14, 2022, 4:49am UTC](https://forum.inductiveautomation.com/t/navigation-with-perspective-tree-onselect-event-not-firing/55001/8 "2022-01-14T04:49:38Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/8/78886bd819a0337cdd5f1c1231b3449424e7e4fd.png)

---

<div class="post-metadata">

**Author:** ![Mason\_Taylor](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Mason\_Taylor](https://forum.inductiveautomation.com/u/Mason_Taylor)\
**Post date:** [January 14, 2022, 4:55am UTC](https://forum.inductiveautomation.com/t/navigation-with-perspective-tree-onselect-event-not-firing/55001/9 "2022-01-14T04:55:35Z")

</div>

I see that came with a recent update, how convenient! That should work perfectly, thanks.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [January 14, 2022, 5:00am UTC](https://forum.inductiveautomation.com/t/navigation-with-perspective-tree-onselect-event-not-firing/55001/10 "2022-01-14T05:00:30Z")

</div>

Not really, april last year feels far, haha time flies ⏲

---

<div class="post-metadata">

**Author:** ![Mason\_Taylor](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Mason\_Taylor](https://forum.inductiveautomation.com/u/Mason_Taylor)\
**Post date:** [January 14, 2022, 5:06am UTC](https://forum.inductiveautomation.com/t/navigation-with-perspective-tree-onselect-event-not-firing/55001/11 "2022-01-14T05:06:52Z")

</div>

Recent for us that is, we just upgraded our installation to 8.1 from 8.0 a couple months back. I didn’t realize we were that far behind!

---

<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:** [January 14, 2022, 1:05pm UTC](https://forum.inductiveautomation.com/t/navigation-with-perspective-tree-onselect-event-not-firing/55001/12 "2022-01-14T13:05:42Z")

</div>

v8.0 is not a Long-Term-Support version. Development on it basically stopped dead in its tracks when 8.1 was released. v8.2, when it releases, if IA continues with long-established pattern, also not be an LTS.
