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)
| 145 | // If the parent is the tree returns nil as the parent |
| 146 | // If not found returns nil and -1 |
| 147 | func (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 |
| 166 | func (t *Tree) onKey(evname string, ev interface{}) { |