FindButton returns the nth Button node (depth-first).
(n int)
| 104 | |
| 105 | // FindButton returns the nth Button node (depth-first). |
| 106 | func (rt *RenderedTree) FindButton(n int) ButtonResult { |
| 107 | count := 0 |
| 108 | var result ButtonResult |
| 109 | walkNodes(rt.root, func(node *viewNode) bool { |
| 110 | if node.kind == viewKindButton && node.button != nil { |
| 111 | if count == n { |
| 112 | result.Label = node.button.label |
| 113 | result.handler = node.button.handler |
| 114 | result.tree = rt |
| 115 | result.found = true |
| 116 | return false |
| 117 | } |
| 118 | count++ |
| 119 | } |
| 120 | return true |
| 121 | }) |
| 122 | return result |
| 123 | } |
| 124 | |
| 125 | // FindButtonByLabel returns the first Button with a matching label. |
| 126 | func (rt *RenderedTree) FindButtonByLabel(label string) ButtonResult { |