diff options
| author | Pietro Gagliardi <[email protected]> | 2014-03-07 15:01:42 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-03-07 15:01:42 -0500 |
| commit | 20dcc48bee158edbeb5b7ba5893f613bfbf11889 (patch) | |
| tree | 70b0adb6a82a44c5d4c4cad4eceb9ba403ccf83a /listbox.go | |
| parent | 874a4b9271c37ec72a6292fa4a045760a43f2b7d (diff) | |
Changed Combobox.Append() and Listbox.Append() to accept multiple strings in one call.
Diffstat (limited to 'listbox.go')
| -rw-r--r-- | listbox.go | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -2,6 +2,7 @@ package ui import ( + "fmt" "sync" ) @@ -25,15 +26,21 @@ func NewListbox(multiple bool, items ...string) (l *Listbox) { return l } -// Append adds an item to the end of the Listbox's list. -func (l *Listbox) Append(what string) (err error) { +// Append adds items to the end of the Listbox's list. +func (l *Listbox) Append(what ...string) (err error) { l.lock.Lock() defer l.lock.Unlock() if l.created { - return l.sysData.append(what) + for i, s := range what { + err := l.sysData.append(s) + if err != nil { + return fmt.Errorf("error adding element %d in Listbox.Append() (%q): %v", i, s, err) + } + } + return nil } - l.initItems = append(l.initItems, what) + l.initItems = append(l.initItems, what...) return nil } |
