Added functions to remove all buttons from forms and from modals. Resolves #259

pull/287/head
Oliver 5 years ago
parent f2bf2be1ba
commit f16ba37c6a

@ -254,12 +254,18 @@ func (f *Form) GetButtonIndex(label string) int {
func (f *Form) Clear(includeButtons bool) *Form {
f.items = nil
if includeButtons {
f.buttons = nil
f.ClearButtons()
}
f.focusedElement = 0
return f
}
// ClearButtons removes all buttons from the form.
func (f *Form) ClearButtons() *Form {
f.buttons = nil
return f
}
// AddFormItem adds a new item to the form. This can be used to add your own
// objects to the form. Note, however, that the Form class will override some
// of its attributes to make it work in the form context. Specifically, these

@ -101,6 +101,12 @@ func (m *Modal) AddButtons(labels []string) *Modal {
return m
}
// ClearButtons removes all buttons from the window.
func (m *Modal) ClearButtons() *Modal {
m.form.ClearButtons()
return m
}
// Focus is called when this primitive receives focus.
func (m *Modal) Focus(delegate func(p Primitive)) {
delegate(m.form)

Loading…
Cancel
Save