FindTextField returns the nth TextField node (depth-first).
(n int)
| 161 | |
| 162 | // FindTextField returns the nth TextField node (depth-first). |
| 163 | func (rt *RenderedTree) FindTextField(n int) TextFieldResult { |
| 164 | count := 0 |
| 165 | var result TextFieldResult |
| 166 | walkNodes(rt.root, func(node *viewNode) bool { |
| 167 | if node.kind == viewKindTextField && node.textField != nil { |
| 168 | if count == n { |
| 169 | if st, ok := node.textField.state.(*StateValue[string]); ok { |
| 170 | result.state = st |
| 171 | } |
| 172 | result.Placeholder = node.textField.placeholder |
| 173 | result.tree = rt |
| 174 | result.found = true |
| 175 | return false |
| 176 | } |
| 177 | count++ |
| 178 | } |
| 179 | return true |
| 180 | }) |
| 181 | return result |
| 182 | } |
| 183 | |
| 184 | // NodeCount returns the total number of nodes of the given kind. |
| 185 | func (rt *RenderedTree) NodeCount(kind string) int { |