Resize RichText elements using data biding + List Data #4747
Unanswered
montovaneli
asked this question in
Q&A
Replies: 1 comment 1 reply
-
I needed that too, so I ended up creating a custom widget that would expose the type List struct {
widget.List
}
func NewList(length func() int, createItem func() fyne.CanvasObject, updateItem func(widget.ListItemID, fyne.CanvasObject)) *List {
list := &List{
List: widget.List{Length: length, CreateItem: createItem, UpdateItem: updateItem},
}
list.ExtendBaseWidget(list)
return list
}
// NewListWithDataWithID creates a new list widget that will display the contents of the provided data but also passes the ListItemID to the updateItem func.
func NewListWithDataWithID(data binding.DataList, createItem func() fyne.CanvasObject, updateItem func(widget.ListItemID, binding.DataItem, fyne.CanvasObject)) *List {
l := NewList(
data.Length,
createItem,
func(i widget.ListItemID, o fyne.CanvasObject) {
item, err := data.GetItem(i)
if err != nil {
fyne.LogError(fmt.Sprintf("Error getting data item %d", i), err)
return
}
updateItem(i, item, o)
})
data.AddListener(binding.NewDataListener(l.Refresh))
return l
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wanted to resize RichText elements in a *widget.List when using data biding + List Data. However, the SetItemHeight function requires the id, meaning we can only use it in NewList. Am I correct or is there any way to do this?
Something like:
Beta Was this translation helpful? Give feedback.
All reactions