Navigation with Perspective Tree: onSelect event not firing

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 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.

You should be using the onItemClicked Event.

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.

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.

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.

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:

just add more lines to the script (that same script) and use
system.perspective.navigate()

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.

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

Not really, april last year feels far, haha time flies :timer_clock:

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!

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.