diff --git a/ExtraWidgets.go b/ExtraWidgets.go index e8eef248..f031583d 100644 --- a/ExtraWidgets.go +++ b/ExtraWidgets.go @@ -239,9 +239,9 @@ type ListBoxWidget struct { } // ListBox creates new ListBoxWidget. -func ListBox(id string, items []string) *ListBoxWidget { +func ListBox(items []string) *ListBoxWidget { return &ListBoxWidget{ - id: id, + id: GenAutoID("##ListBox"), width: 0, height: 0, border: true, @@ -253,6 +253,11 @@ func ListBox(id string, items []string) *ListBoxWidget { } } +func (l *ListBoxWidget) ID(id string) *ListBoxWidget { + l.id = id + return l +} + func (l *ListBoxWidget) SelectedIndex(i *int32) *ListBoxWidget { l.selectedIndex = i return l diff --git a/examples/widgets/widgets.go b/examples/widgets/widgets.go index e449b2e3..86db33f2 100644 --- a/examples/widgets/widgets.go +++ b/examples/widgets/widgets.go @@ -203,7 +203,7 @@ func loop() { Size(g.Auto, g.Auto), ), g.TabItem("ListBox").Layout( - g.ListBox("ListBox1", []string{"List item 1", "List item 2", "List item 3"}), + g.ListBox([]string{"List item 1", "List item 2", "List item 3"}), ), g.TabItem("Table").Layout( g.Table().