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

Method OnAdd

core/widget.go:279–290  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

277// It should be called by all other OnAdd functions defined
278// by widget types.
279func (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,

Callers

nothing calls this directly

Calls 1

parentWidgetMethod · 0.95

Tested by

no test coverage detected