FindText returns the nth Text node's value (depth-first).
(n int)
| 81 | |
| 82 | // FindText returns the nth Text node's value (depth-first). |
| 83 | func (rt *RenderedTree) FindText(n int) TextResult { |
| 84 | count := 0 |
| 85 | var result TextResult |
| 86 | walkNodes(rt.root, func(node *viewNode) bool { |
| 87 | if node.kind == viewKindText && node.text != nil { |
| 88 | if count == n { |
| 89 | switch tc := node.text.content.(type) { |
| 90 | case staticText: |
| 91 | result.Value = string(tc) |
| 92 | case reactiveText: |
| 93 | result.Value = tc.signal.Value() |
| 94 | } |
| 95 | result.found = true |
| 96 | return false |
| 97 | } |
| 98 | count++ |
| 99 | } |
| 100 | return true |
| 101 | }) |
| 102 | return result |
| 103 | } |
| 104 | |
| 105 | // FindButton returns the nth Button node (depth-first). |
| 106 | func (rt *RenderedTree) FindButton(n int) ButtonResult { |