Form now has a Clear() function. Resolves #32

This commit is contained in:
Oliver 2018-01-15 10:04:03 +01:00
parent 9608f5b3b5
commit c105638ec3
2 changed files with 11 additions and 1 deletions

2
box.go
View File

@ -94,7 +94,7 @@ func (b *Box) GetInnerRect() (int, int, int, int) {
height - b.paddingTop - b.paddingBottom
}
// SetRect sets a new position of the rectangle.
// SetRect sets a new position of the primitive.
func (b *Box) SetRect(x, y, width, height int) {
b.x = x
b.y = y

10
form.go
View File

@ -191,6 +191,16 @@ func (f *Form) AddButton(label string, selected func()) *Form {
return f
}
// Clear removes all input elements from the form, including the buttons if
// specified.
func (f *Form) Clear(includeButtons bool) *Form {
f.items = nil
if includeButtons {
f.buttons = nil
}
return f
}
// GetFormItem returns the form element at the given position, starting with
// index 0. Elements are referenced in the order they were added. Buttons are
// not included.