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

Method Init

core/values.go:29–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27func (lb *ListButton) WidgetValue() any { return &lb.Slice }
28
29func (lb *ListButton) Init() {
30 lb.Button.Init()
31 lb.SetType(ButtonTonal).SetIcon(icons.Edit)
32 lb.Updater(func() {
33 lb.SetText(labels.FriendlySliceLabel(reflect.ValueOf(lb.Slice)))
34 })
35 InitValueButton(lb, true, func(d *Body) {
36 up := reflectx.Underlying(reflect.ValueOf(lb.Slice))
37 if up.Type().Kind() != reflect.Array && reflectx.NonPointerType(reflectx.SliceElementType(lb.Slice)).Kind() == reflect.Struct {
38 tb := NewTable(d).SetSlice(lb.Slice)
39 tb.SetValueTitle(lb.ValueTitle).SetReadOnly(lb.IsReadOnly())
40 d.AddAppBar(tb.MakeToolbar)
41 } else {
42 sv := NewList(d).SetSlice(lb.Slice)
43 sv.SetValueTitle(lb.ValueTitle).SetReadOnly(lb.IsReadOnly())
44 d.AddAppBar(sv.MakeToolbar)
45 }
46 })
47}
48
49// FormButton represents a struct value with a button that opens a [Form].
50type FormButton struct {

Callers

nothing calls this directly

Calls 15

FriendlySliceLabelFunction · 0.92
UnderlyingFunction · 0.92
NonPointerTypeFunction · 0.92
SliceElementTypeFunction · 0.92
InitValueButtonFunction · 0.85
NewListFunction · 0.85
UpdaterMethod · 0.80
KindMethod · 0.80
SetValueTitleMethod · 0.80
AddAppBarMethod · 0.80
NewTableFunction · 0.70
InitMethod · 0.65

Tested by

no test coverage detected