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

Function ResetWidgetValue

core/value.go:83–88  ·  view source on GitHub ↗

ResetWidgetValue resets the [Value] if it was already bound to another value previously. We first need to reset the widget value to zero to avoid any issues with the pointer from the old value persisting and being updated. For example, that issue happened with slice and map pointers persisting in fo

(vw Value)

Source from the content-addressed store, hash-verified

81// It should not be called by end-user code; it must be exported since it is referenced
82// in a generic function added to yaegi ([Bind]).
83func ResetWidgetValue(vw Value) {
84 rv := reflect.ValueOf(vw.WidgetValue())
85 if rv.IsValid() && rv.Type().Kind() == reflect.Pointer {
86 rv.Elem().SetZero()
87 }
88}
89
90// joinValueTitle returns a [WidgetBase.ValueTitle] string composed
91// of two elements, with a • separator, handling the cases where

Callers 3

BindFunction · 0.85
bindMapKeyFunction · 0.85
bindMapValueFunction · 0.85

Calls 6

KindMethod · 0.80
ElemMethod · 0.80
WidgetValueMethod · 0.65
TypeMethod · 0.65
IsValidMethod · 0.45
SetZeroMethod · 0.45

Tested by

no test coverage detected