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 /combobox.go | |
| parent | 874a4b9271c37ec72a6292fa4a045760a43f2b7d (diff) | |
Changed Combobox.Append() and Listbox.Append() to accept multiple strings in one call.
Diffstat (limited to 'combobox.go')
| -rw-r--r-- | combobox.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/combobox.go b/combobox.go index ac3523a..571bcba 100644 --- a/combobox.go +++ b/combobox.go @@ -2,6 +2,7 @@ package ui import ( + "fmt" "sync" ) @@ -34,15 +35,21 @@ func NewEditableCombobox(items ...string) *Combobox { return newCombobox(true, items...) } -// Append adds an item to the end of the Combobox's list. -func (c *Combobox) Append(what string) (err error) { +// Append adds items to the end of the Combobox's list. +func (c *Combobox) Append(what ...string) (err error) { c.lock.Lock() defer c.lock.Unlock() if c.created { - return c.sysData.append(what) + for i, s := range what { + err := c.sysData.append(s) + if err != nil { + return fmt.Errorf("error adding element %d in Combobox.Append() (%q): %v", i, s, err) + } + } + return nil } - c.initItems = append(c.initItems, what) + c.initItems = append(c.initItems, what...) return nil } |
