Skip to content

Commit

Permalink
ListBoxWidget: fix ID handling
Browse files Browse the repository at this point in the history
don't require id argument in ListBox method, use AutoID instead
  • Loading branch information
gucio321 committed Oct 25, 2023
1 parent 04cd961 commit bc0820b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions ExtraWidgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/widgets/widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down

0 comments on commit bc0820b

Please sign in to comment.