In Form, changed GetElement() to GetFormItem() for consistency reasons.

This commit is contained in:
Oliver 2018-01-13 13:07:05 +01:00
parent 946d2620b6
commit 38d663c267
2 changed files with 4 additions and 4 deletions

View File

@ -17,8 +17,8 @@ func main() {
AddCheckbox("年龄 18+", false, nil).
AddPasswordField("密码", "", 10, '*', nil).
AddButton("保存", func() {
_, title := form.GetElement(0).(*tview.DropDown).GetCurrentOption()
userName := form.GetElement(1).(*tview.InputField).GetText()
_, title := form.GetFormItem(0).(*tview.DropDown).GetCurrentOption()
userName := form.GetFormItem(1).(*tview.InputField).GetText()
alert(pages, "alert-dialog", fmt.Sprintf("保存成功,%s %s", userName, title))
}).

View File

@ -191,10 +191,10 @@ func (f *Form) AddButton(label string, selected func()) *Form {
return f
}
// GetElement returns the form element at the given position, starting with
// 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.
func (f *Form) GetElement(index int) Primitive {
func (f *Form) GetFormItem(index int) FormItem {
return f.items[index]
}