widgetPrevFunc returns the previous widget in the tree, including Parts, which are considered to come after children, continuing until the given function returns true. nil if no more.
(w Widget, fun func(w Widget) bool)
| 539 | // continuing until the given function returns true. |
| 540 | // nil if no more. |
| 541 | func widgetPrevFunc(w Widget, fun func(w Widget) bool) Widget { |
| 542 | for { |
| 543 | pw := widgetPrev(w) |
| 544 | if pw == nil { |
| 545 | return nil |
| 546 | } |
| 547 | if fun(pw) { |
| 548 | return pw |
| 549 | } |
| 550 | if pw == w { |
| 551 | slog.Error("WidgetPrevFunc", "start", w, "pw == wi", pw) |
| 552 | return nil |
| 553 | } |
| 554 | w = pw |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | // WidgetTooltip is the base implementation of [Widget.WidgetTooltip], |
| 559 | // which just returns [WidgetBase.Tooltip] and [WidgetBase.DefaultTooltipPos]. |