View Single Post
  #3  
Old 02-04-2016, 04:11 AM
Erikvdb Erikvdb is offline
Member
 
Join Date: May 2013
Posts: 63
Highlighter works, you just need to declare the sub-nodes as objects.

Code:
gallery = viz.addChild('gallery.ive')
nodes = {}

for name in gallery.getNodeNames():
    node = gallery.getChild(name) #create child object
    nodes[node] = name #store in dict with its name

from tools import highlighter
tool = highlighter.Highlighter()
tool.setItems(nodes.keys())

def onHighlight(e):
    if e.new in nodes:
        print '{} is highlighted'.format(nodes[e.new])

viz.callback(highlighter.HIGHLIGHT_EVENT,onHighlight)
There might be an easier way to get the node name from the selected object so you don't need to store it in a dictionary, but hey.
Reply With Quote