NewMenuFromStrings constructs a new menu from given list of strings, calling the given function with the index of the selected string. if string == sel, that menu item is selected initially.
(strs []string, sel string, fun func(idx int))
| 182 | // calling the given function with the index of the selected string. |
| 183 | // if string == sel, that menu item is selected initially. |
| 184 | func NewMenuFromStrings(strs []string, sel string, fun func(idx int)) *Scene { |
| 185 | return newMenuScene(func(m *Scene) { |
| 186 | for i, s := range strs { |
| 187 | b := NewButton(m).SetText(s) |
| 188 | b.OnClick(func(e events.Event) { |
| 189 | fun(i) |
| 190 | }) |
| 191 | if s == sel { |
| 192 | b.SetSelected(true) |
| 193 | } |
| 194 | } |
| 195 | }) |
| 196 | } |
no test coverage detected