MCPcopy Create free account
hub / github.com/cogentcore/core / widgetPrev

Function widgetPrev

core/widget.go:488–501  ·  view source on GitHub ↗

widgetPrev returns the previous widget in the tree, including Parts, which are considered to come after Children. nil if no more.

(w Widget)

Source from the content-addressed store, hash-verified

486// including Parts, which are considered to come after Children.
487// nil if no more.
488func 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,

Callers 1

widgetPrevFuncFunction · 0.85

Calls 5

widgetLastChildPartsFunction · 0.85
IndexInParentMethod · 0.80
ChildMethod · 0.80
AsWidgetMethod · 0.65
AsTreeMethod · 0.65

Tested by

no test coverage detected