Panic when attempting to add an invalid FormItem

This commit is contained in:
Trevor Slocum 2020-10-02 16:31:31 -07:00
parent db81e43e00
commit 3d1844e33b
2 changed files with 6 additions and 0 deletions

View File

@ -9,6 +9,7 @@ v1.5.0 (WIP)
- Revamp FormItem styling as FormItem.SetAttributes
- Provide DropDownOption in DropDown handlers
- Provide ListItem in List handlers
- Panic when attempting to add an invalid FormItem
v1.4.9 (2020-09-08)
- Add InputField.GetCursorPosition and InputField.SetCursorPosition

View File

@ -1,6 +1,7 @@
package cview
import (
"reflect"
"sync"
"github.com/gdamore/tcell/v2"
@ -454,6 +455,10 @@ func (f *Form) AddFormItem(item FormItem) *Form {
f.Lock()
defer f.Unlock()
if reflect.ValueOf(item).IsNil() {
panic("Invalid FormItem")
}
f.items = append(f.items, item)
return f
}