Skip to content

Commit

Permalink
Fix package lookup for canvas objects
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Oct 17, 2024
1 parent 713b7f8 commit 312ca09
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/gui/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ func packagesRequired(obj fyne.CanvasObject, meta map[fyne.CanvasObject]map[stri
if info != nil && info.IsContainer() {
objs = info.Children(obj)
} else {
if w, ok := obj.(fyne.Widget); ok {
return packagesRequiredForWidget(w)
}
return packagesRequiredForWidget(obj)
}
}

Expand All @@ -137,13 +135,17 @@ func packagesRequired(obj fyne.CanvasObject, meta map[fyne.CanvasObject]map[stri
return ret
}

func packagesRequiredForWidget(w fyne.Widget) []string {
func packagesRequiredForWidget(w fyne.CanvasObject) []string {
name := reflect.TypeOf(w).String()
if pkgs := guidefs.Lookup(name).Packages; pkgs != nil {
return pkgs(w)
}

return []string{"widget"}
if _, ok := w.(fyne.Widget); ok {
return []string{"widget"}
}

return []string{}
}

func varsRequired(obj fyne.CanvasObject, props map[fyne.CanvasObject]map[string]string) []string {
Expand Down

0 comments on commit 312ca09

Please sign in to comment.