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)
| 239 | // its position relative to the parent. |
| 240 | // If not found returns nil and -1 |
| 241 | func (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 |