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

Method Init

core/values.go:134–161  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

132func (ib *IconButton) WidgetValue() any { return &ib.Icon }
133
134func (ib *IconButton) Init() {
135 ib.Button.Init()
136 ib.Updater(func() {
137 if !ib.Icon.IsSet() {
138 ib.SetText("Select an icon")
139 } else {
140 ib.SetText("")
141 }
142 if ib.IsReadOnly() {
143 ib.SetType(ButtonText)
144 if !ib.Icon.IsSet() {
145 ib.SetText("").SetIcon(icons.Blank)
146 }
147 } else {
148 ib.SetType(ButtonTonal)
149 }
150 })
151 InitValueButton(ib, false, func(d *Body) {
152 d.SetTitle("Select an icon")
153 si := 0
154 used := maps.Keys(icons.Used)
155 ls := NewList(d)
156 ls.SetSlice(&used).SetSelectedValue(ib.Icon).BindSelect(&si)
157 ls.OnChange(func(e events.Event) {
158 ib.Icon = used[si]
159 })
160 })
161}
162
163// FontName is used to specify a font family name.
164// It results in a [FontButton] [Value].

Callers

nothing calls this directly

Calls 15

InitValueButtonFunction · 0.85
NewListFunction · 0.85
UpdaterMethod · 0.80
IsSetMethod · 0.80
KeysMethod · 0.80
BindSelectMethod · 0.80
SetSelectedValueMethod · 0.80
InitMethod · 0.65
SetIconMethod · 0.65
SetTitleMethod · 0.65
SetTextMethod · 0.45
IsReadOnlyMethod · 0.45

Tested by

no test coverage detected