From c105638ec30c991a9569ab4d0831af20011a6864 Mon Sep 17 00:00:00 2001 From: Oliver <480930+rivo@users.noreply.github.com> Date: Mon, 15 Jan 2018 10:04:03 +0100 Subject: [PATCH] Form now has a Clear() function. Resolves #32 --- box.go | 2 +- form.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/box.go b/box.go index ca5df43..fa77496 100644 --- a/box.go +++ b/box.go @@ -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 diff --git a/form.go b/form.go index ca86eca..2b88fe3 100644 --- a/form.go +++ b/form.go @@ -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.