From 7aa84e26f0405b12ab9bbeb6001ec1af64e7a006 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 25 Feb 2014 15:13:37 -0500 Subject: [PATCH] Split NewCombobox() into separate functions NewCombobox() and NewEditableCombobox(). --- combobox.go | 13 +++++++++++-- main_test.go | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/combobox.go b/combobox.go index 255bcf0..d01badd 100644 --- a/combobox.go +++ b/combobox.go @@ -15,8 +15,7 @@ type Combobox struct { initItems []string } -// NewCombobox makes a new combobox with the given items. If editable is true, the combobox is editable. -func NewCombobox(editable bool, items ...string) (c *Combobox) { +func newCombobox(editable bool, items ...string) (c *Combobox) { c = &Combobox{ sysData: mksysdata(c_combobox), initItems: items, @@ -25,6 +24,16 @@ func NewCombobox(editable bool, items ...string) (c *Combobox) { return c } +// NewCombobox makes a new Combobox with the given items. +func NewCombobox(items ...string) *Combobox { + return newCombobox(false, items...) +} + +// NewEditableCombobox makes a new editable Combobox with the given items. +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) { c.lock.Lock() diff --git a/main_test.go b/main_test.go index 4960dd3..23a2e16 100644 --- a/main_test.go +++ b/main_test.go @@ -13,8 +13,8 @@ func TestMain(t *testing.T) { b2 := NewButton("Or Me") s2 := NewStack(Horizontal, b, b2) c := NewCheckbox("Check Me") - cb1 := NewCombobox(true, "You can edit me!", "Yes you can!", "Yes you will!") - cb2 := NewCombobox(false, "You can't edit me!", "No you can't!", "No you won't!") + cb1 := NewEditableCombobox("You can edit me!", "Yes you can!", "Yes you will!") + cb2 := NewCombobox("You can't edit me!", "No you can't!", "No you won't!") e := NewLineEdit("Enter text here too") l := NewLabel("This is a label") b3 := NewButton("List Info")