addButtonItems adds to the given items all of the buttons under the given parent. It navigates through button menus to find other buttons using a recursive approach that updates path with context about the original button menu. Consumers of this function should typically set path to "".
(items *[]ChooserItem, parent tree.Node, path string)
| 283 | // about the original button menu. Consumers of this function should |
| 284 | // typically set path to "". |
| 285 | func addButtonItems(items *[]ChooserItem, parent tree.Node, path string) { |
| 286 | for _, kid := range parent.AsTree().Children { |
| 287 | bt := AsButton(kid) |
| 288 | if bt == nil || bt.IsDisabled() { |
| 289 | continue |
| 290 | } |
| 291 | label := bt.Text |
| 292 | if label == "" { |
| 293 | label = bt.Tooltip |
| 294 | } |
| 295 | if bt.HasMenu() { |
| 296 | tmps := NewScene() |
| 297 | bt.Menu(tmps) |
| 298 | npath := path |
| 299 | if npath != "" { |
| 300 | npath += " > " |
| 301 | } |
| 302 | if bt.Name != "overflow-menu" { |
| 303 | npath += label |
| 304 | } |
| 305 | addButtonItems(items, tmps, npath) |
| 306 | continue |
| 307 | } |
| 308 | if path != "" { |
| 309 | label = path + " > " + label |
| 310 | } |
| 311 | *items = append(*items, ChooserItem{ |
| 312 | Text: label, |
| 313 | Icon: bt.Icon, |
| 314 | Tooltip: bt.Tooltip, |
| 315 | Func: func() { |
| 316 | bt.Send(events.Click) |
| 317 | }, |
| 318 | }) |
| 319 | // after the quit button, there are the render wins, |
| 320 | // which we do not want to show here as we are already |
| 321 | // showing the stages |
| 322 | if bt.Name == "quit-app" { |
| 323 | break |
| 324 | } |
| 325 | } |
| 326 | } |
no test coverage detected