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

Method FindChild

gui/tree.go:147–163  ·  view source on GitHub ↗

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

(child IPanel)

Source from the content-addressed store, hash-verified

145// If the parent is the tree returns nil as the parent
146// If not found returns nil and -1
147func (t *Tree) FindChild(child IPanel) (*TreeNode, int) {
148
149 for idx := 0; idx < t.List.Len(); idx++ {
150 curr := t.List.ItemAt(idx)
151 if curr == child {
152 return nil, idx
153 }
154 node, ok := curr.(*TreeNode)
155 if ok {
156 par, pos := node.FindChild(child)
157 if pos >= 0 {
158 return par, pos
159 }
160 }
161 }
162 return nil, -1
163}
164
165// onKey receives key down events for the embedded list
166func (t *Tree) onKey(evname string, ev interface{}) {

Callers 1

FindChildMethod · 0.45

Calls 2

LenMethod · 0.45
ItemAtMethod · 0.45

Tested by

no test coverage detected