(err error, widget Widget)
| 60 | } |
| 61 | |
| 62 | func (ttep *ToolTipErrorPresenter) PresentError(err error, widget Widget) { |
| 63 | if ttep.toolTip == nil { |
| 64 | return |
| 65 | } |
| 66 | |
| 67 | if err == nil && widget == ttep.curWidget { |
| 68 | ttep.untrack() |
| 69 | } |
| 70 | |
| 71 | if err == nil { |
| 72 | ttep.toolTip.RemoveTool(widget) |
| 73 | delete(ttep.widget2error, widget) |
| 74 | } else { |
| 75 | ttep.toolTip.addTrackedTool(widget) |
| 76 | ttep.widget2error[widget] = err |
| 77 | } |
| 78 | |
| 79 | var found bool |
| 80 | if widget != nil { |
| 81 | walkDescendants(widget.Form().AsFormBase().clientComposite, func(w Window) bool { |
| 82 | wt := w.(Widget) |
| 83 | |
| 84 | if !found { |
| 85 | if e, ok := ttep.widget2error[wt]; ok { |
| 86 | err, widget, found = e, wt, true |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | if !found && wt == ttep.curWidget || wt != widget || err == nil { |
| 91 | wt.GraphicsEffects().Remove(ValidationErrorEffect) |
| 92 | } |
| 93 | |
| 94 | return true |
| 95 | }) |
| 96 | } |
| 97 | |
| 98 | if found { |
| 99 | if widget != ttep.curWidget { |
| 100 | ttep.untrack() |
| 101 | } |
| 102 | |
| 103 | if ve, ok := err.(*ValidationError); ok { |
| 104 | ttep.toolTip.SetErrorTitle(ve.title) |
| 105 | ttep.toolTip.SetText(widget, ve.message) |
| 106 | } else { |
| 107 | ttep.toolTip.SetErrorTitle(tr("Invalid Input")) |
| 108 | ttep.toolTip.SetText(widget, err.Error()) |
| 109 | } |
| 110 | |
| 111 | if widget != ttep.curWidget { |
| 112 | ttep.track(widget) |
| 113 | |
| 114 | if effects := widget.GraphicsEffects(); !effects.Contains(ValidationErrorEffect) { |
| 115 | effects.Add(ValidationErrorEffect) |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | } |
nothing calls this directly
no test coverage detected