AddButtons adds buttons to the window.
(labels []string)
| 110 | |
| 111 | // AddButtons adds buttons to the window. |
| 112 | func (m *WideModal) AddButtons(labels []string) *WideModal { |
| 113 | for index, label := range labels { |
| 114 | m.buttons = append(m.buttons, label) |
| 115 | func(i int, l string) { |
| 116 | m.form.AddButton(label, func() { |
| 117 | if m.done != nil { |
| 118 | m.done(i, l) |
| 119 | } |
| 120 | }) |
| 121 | button := m.form.GetButton(m.form.GetButtonCount() - 1) |
| 122 | button.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { |
| 123 | switch event.Key() { |
| 124 | case tcell.KeyDown, tcell.KeyRight: |
| 125 | return tcell.NewEventKey(tcell.KeyTab, 0, tcell.ModNone) |
| 126 | case tcell.KeyUp, tcell.KeyLeft: |
| 127 | return tcell.NewEventKey(tcell.KeyBacktab, 0, tcell.ModNone) |
| 128 | } |
| 129 | return event |
| 130 | }) |
| 131 | }(index, label) |
| 132 | } |
| 133 | return m |
| 134 | } |
| 135 | |
| 136 | // ClearButtons removes all buttons from the window. |
| 137 | func (m *WideModal) ClearButtons() *WideModal { |
no outgoing calls
no test coverage detected