Unfold nodes with a script

Unfold nodes with a script

Postby dgm5555 » Thu Feb 13, 2014 12:07 pm

I'm trying to write a script to show an arbitrary node which could be at any depth, but tried various things which don't work
The first trial causes a signature error. The second two appear to do nothing

Code: Select all
curNodes.setfolded(false)


Code: Select all
curNodes.folded = false


Code: Select all
rootNode = node.map.root
curParents = []
curParent = curNodes
while (!curParent == rootNode) {
    curParent = it.getParent()
    curParents.add(curParent)
}
curParents.each{ it.folded = false }   // unfold to make the selected nodes visible
dgm5555
 
Posts: 4
Joined: Sun Feb 02, 2014 9:19 pm

Re: Unfold nodes with a script

Postby jokro » Thu Feb 13, 2014 2:16 pm

Make Example Map with a,b,c as child, grandchild, grandgrandchild
Node a folded, hence b and c invisible
Script first finds node b
Then unfolds parents

Code: Select all
def list=map.root.find({it.text=="b"})
def n=list[0]
unfoldParents(n)

void unfoldParents(def n){
    if (n!=map.root){
        n.folded=false
        unfoldParents(n.parent)
    }
}


Have fun
Regards
Jodi
jokro
 
Posts: 486
Joined: Sun Jul 24, 2011 2:56 pm


Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron