widgetPrev returns the previous widget in the tree, including Parts, which are considered to come after Children. nil if no more.
(w Widget)
| 486 | // including Parts, which are considered to come after Children. |
| 487 | // nil if no more. |
| 488 | func widgetPrev(w Widget) Widget { |
| 489 | wb := w.AsWidget() |
| 490 | if wb.Parent == nil { |
| 491 | return nil |
| 492 | } |
| 493 | parent := wb.Parent.(Widget) |
| 494 | myidx := wb.IndexInParent() |
| 495 | if myidx > 0 { |
| 496 | nn := parent.AsTree().Child(myidx - 1).(Widget) |
| 497 | return widgetLastChildParts(nn) // go to parts |
| 498 | } |
| 499 | // we were children, done |
| 500 | return parent |
| 501 | } |
| 502 | |
| 503 | // widgetLastChildParts returns the last child under given node, |
| 504 | // or node itself if no children. Starts with Parts, |
no test coverage detected