MCPcopy Index your code
hub / github.com/g3n/engine / FindChild

Method FindChild

gui/tree.go:241–256  ·  view source on GitHub ↗

FindChild searches for the specified child in this node and all its children. If found, returns the parent node and its position relative to the parent. If not found returns nil and -1

(child IPanel)

Source from the content-addressed store, hash-verified

239// its position relative to the parent.
240// If not found returns nil and -1
241func (n *TreeNode) FindChild(child IPanel) (*TreeNode, int) {
242
243 for pos, curr := range n.items {
244 if curr == child {
245 return n, pos
246 }
247 node, ok := curr.(*TreeNode)
248 if ok {
249 par, pos := node.FindChild(child)
250 if par != nil {
251 return par, pos
252 }
253 }
254 }
255 return nil, -1
256}
257
258// InsertAt inserts a child panel at the specified position in this node
259// If the position is invalid, the function panics

Callers

nothing calls this directly

Calls 1

FindChildMethod · 0.45

Tested by

no test coverage detected