OnAdd is called when widgets are added to a parent. It sets the scene of the widget to its widget parent. It should be called by all other OnAdd functions defined by widget types.
()
| 277 | // It should be called by all other OnAdd functions defined |
| 278 | // by widget types. |
| 279 | func (wb *WidgetBase) OnAdd() { |
| 280 | if pwb := wb.parentWidget(); pwb != nil { |
| 281 | wb.Scene = pwb.Scene |
| 282 | } |
| 283 | if wb.Parts != nil { |
| 284 | // the Scene of the Parts may not have been set yet if they were made in Init |
| 285 | wb.Parts.Scene = wb.Scene |
| 286 | } |
| 287 | if wb.Scene != nil && wb.Scene.WidgetInit != nil { |
| 288 | wb.Scene.WidgetInit(wb.This.(Widget)) |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | // setScene sets the Scene pointer for this widget and all of its children. |
| 293 | // This can be necessary when creating widgets outside the usual New* paradigm, |
nothing calls this directly
no test coverage detected