(options ...string)
| 1019 | } |
| 1020 | |
| 1021 | func (dropdown *Dropdown) SetOptions(options ...string) { |
| 1022 | |
| 1023 | dropdown.Options = append([]string{}, options...) |
| 1024 | |
| 1025 | for _, b := range dropdown.Choices { |
| 1026 | b.Destroy() |
| 1027 | } |
| 1028 | |
| 1029 | dropdown.Choices = []*Button{} |
| 1030 | |
| 1031 | for i, o := range options { |
| 1032 | index := i |
| 1033 | b := NewButton(o, nil, nil, dropdown.WorldSpace, func() { |
| 1034 | dropdown.ChosenIndex = index |
| 1035 | dropdown.Open = false |
| 1036 | |
| 1037 | if dropdown.Property != nil { |
| 1038 | dropdown.Property.Set(dropdown.Options[dropdown.ChosenIndex]) |
| 1039 | } |
| 1040 | |
| 1041 | if dropdown.OnChoose != nil { |
| 1042 | dropdown.OnChoose(index) |
| 1043 | } |
| 1044 | }) |
| 1045 | b.BackgroundColor = getThemeColor(GUIMenuColor).Accent() |
| 1046 | dropdown.Choices = append(dropdown.Choices, b) |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | func (dropdown *Dropdown) Update() { |
| 1051 |
no test coverage detected