|
|
|
@ -154,6 +154,20 @@ func (f *Form) SetButtonTextColor(color tcell.Color) *Form {
|
|
|
|
|
return f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetFocus shifts the focus to the form element with the given index, counting
|
|
|
|
|
// non-button items first and buttons last. Note that this index is only used
|
|
|
|
|
// when the form itself receives focus.
|
|
|
|
|
func (f *Form) SetFocus(index int) *Form {
|
|
|
|
|
if index < 0 {
|
|
|
|
|
f.focusedElement = 0
|
|
|
|
|
} else if index >= len(f.items)+len(f.buttons) {
|
|
|
|
|
f.focusedElement = len(f.items) + len(f.buttons)
|
|
|
|
|
} else {
|
|
|
|
|
f.focusedElement = index
|
|
|
|
|
}
|
|
|
|
|
return f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// AddInputField adds an input field to the form. It has a label, an optional
|
|
|
|
|
// initial value, a field width (a value of 0 extends it as far as possible),
|
|
|
|
|
// an optional accept function to validate the item's value (set to nil to
|
|
|
|
|