MCPcopy Create free account
hub / github.com/cogentcore/core / ParentLevel

Method ParentLevel

tree/nodebase.go:161–173  ·  view source on GitHub ↗

ParentLevel finds a given potential parent node recursively up the hierarchy, returning the level above the current node that the parent was found, and -1 if not found.

(parent Node)

Source from the content-addressed store, hash-verified

159// hierarchy, returning the level above the current node that the parent was
160// found, and -1 if not found.
161func (n *NodeBase) ParentLevel(parent Node) int {
162 parLev := -1
163 level := 0
164 n.WalkUpParent(func(k Node) bool {
165 if k == parent {
166 parLev = level
167 return Break
168 }
169 level++
170 return Continue
171 })
172 return parLev
173}
174
175// ParentByName finds first parent recursively up hierarchy that matches
176// the given name. It returns nil if not found.

Callers 3

ContainsFocusMethod · 0.80
ValidateMethod · 0.80
OutMethod · 0.80

Calls 1

WalkUpParentMethod · 0.95

Tested by

no test coverage detected