MCPcopy Create free account
hub / github.com/SolarLune/masterplan / SetChoices

Method SetChoices

gui.go:1204–1228  ·  view source on GitHub ↗
(choices ...string)

Source from the content-addressed store, hash-verified

1202}
1203
1204func (bg *ButtonGroup) SetChoices(choices ...string) {
1205
1206 for _, b := range bg.Buttons {
1207 b.Destroy()
1208 }
1209
1210 bg.Buttons = []*Button{}
1211 bg.Options = choices
1212
1213 for i, c := range choices {
1214 index := i
1215 newButton := NewButton(c, nil, nil, bg.WorldSpace, func() {
1216 bg.ChosenIndex = index
1217 if bg.Property != nil {
1218 bg.Property.Set(bg.Buttons[bg.ChosenIndex].Label.TextAsString())
1219 }
1220 if bg.OnChoose != nil {
1221 bg.OnChoose(index)
1222 }
1223 })
1224 newButton.Highlighter.HighlightMode = HighlightRing
1225 bg.Buttons = append(bg.Buttons, newButton)
1226 }
1227
1228}
1229
1230func (bg *ButtonGroup) Update() {
1231

Callers 1

NewButtonGroupFunction · 0.95

Calls 4

NewButtonFunction · 0.85
TextAsStringMethod · 0.80
DestroyMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected