widget.List
import "fyne.io/fyne/v2/widget"
Usage
type List
type List struct {
BaseWidget
// Length is a callback for returning the number of items in the list.
Length func() int `json:"-"`
// CreateItem is a callback invoked to create a new widget to render
// a row in the list.
CreateItem func() fyne.CanvasObject `json:"-"`
// UpdateItem is a callback invoked to update a list row widget
// to display a new row in the list. The UpdateItem callback should
// only update the given item, it should not invoke APIs that would
// change other properties of the list itself.
UpdateItem func(id ListItemID, item fyne.CanvasObject) `json:"-"`
// OnSelected is a callback to be notified when a given item
// in the list has been selected.
OnSelected func(id ListItemID) `json:"-"`
// OnUnselected is a callback to be notified when a given item
// in the list has been unselected.
OnUnselected func(id ListItemID) `json:"-"`
// HideSeparators hides the separators between list rows
//
// Since: 2.5
HideSeparators bool
// OnHighlighted is a callback to be notified when a given item
// in the list has been highlighted by keyboard navigation and mouse hover
//
// Since: 2.8
OnHighlighted func(id ListItemID) `json:"-"`
}
List is a widget that pools list items for performance and lays the items out in a vertical direction inside of a scroller. By default, List requires that all items are the same size, but specific rows can have their heights set with SetItemHeight.
1.4func NewList
func NewList(length func() int, createItem func() fyne.CanvasObject, updateItem func(ListItemID, fyne.CanvasObject)) *List
NewList creates and returns a list widget for displaying items in a vertical layout with scrolling and caching for performance.
1.4func NewListWithData
func NewListWithData(data binding.DataList, createItem func() fyne.CanvasObject, updateItem func(binding.DataItem, fyne.CanvasObject)) *List
NewListWithData creates a new list widget that will display the contents of the provided data.
2.0func (*List) Bind
func (l *List) Bind(data binding.DataList, update func(di binding.DataItem, o fyne.CanvasObject))
Bind connects the specified data source to this List. The current contents of the DataList will be used to determine length and content any changes in the data will cause the widget to update. The same types of item will be used but the replacement update function will be called when an item should update. Upon binding all items will update.
2.8func (*List) CreateRenderer
func (l *List) CreateRenderer() fyne.WidgetRenderer
CreateRenderer is a private method to Fyne which links this widget to its renderer.
func (*List) FocusGained
func (l *List) FocusGained()
FocusGained is called after this List has gained focus.
func (*List) FocusLost
func (l *List) FocusLost()
FocusLost is called after this List has lost focus.
func (*List) GetScrollOffset
func (l *List) GetScrollOffset() float32
GetScrollOffset returns the current scroll offset position
2.5func (*List) Highlight
func (l *List) Highlight(id ListItemID)
Highlight scrolls to the item represented by id and highlights it
2.8func (*List) MinSize
func (l *List) MinSize() fyne.Size
MinSize returns the size that this widget should not shrink below.
func (*List) Refresh
func (l *List) Refresh()
Refresh causes this List to be redrawn in its current state
func (*List) RefreshItem
func (l *List) RefreshItem(id ListItemID)
RefreshItem refreshes a single item, specified by the item ID passed in.
2.4func (*List) Resize
func (l *List) Resize(s fyne.Size)
Resize is called when this list should change size. We refresh to ensure invisible items are drawn.
func (*List) ScrollTo
func (l *List) ScrollTo(id ListItemID)
ScrollTo scrolls to the item represented by id
2.1func (*List) ScrollToBottom
func (l *List) ScrollToBottom()
ScrollToBottom scrolls to the end of the list
2.1func (*List) ScrollToOffset
func (l *List) ScrollToOffset(offset float32)
ScrollToOffset scrolls the list to the given offset position.
2.5func (*List) ScrollToTop
func (l *List) ScrollToTop()
ScrollToTop scrolls to the start of the list
2.1func (*List) Select
func (l *List) Select(id ListItemID)
Select add the item identified by the given ID to the selection.
func (*List) SetItemHeight
func (l *List) SetItemHeight(id ListItemID, height float32)
SetItemHeight supports changing the height of the specified list item. Items normally take the height of the template returned from the CreateItem callback. The height parameter uses the same units as a fyne.Size type and refers to the internal content height not including the divider size.
2.3func (*List) TypedKey
func (l *List) TypedKey(event *fyne.KeyEvent)
TypedKey is called if a key event happens while this List is focused.
func (*List) TypedRune
func (l *List) TypedRune(_ rune)
TypedRune is called if a text event happens while this List is focused.
func (*List) Unbind
func (l *List) Unbind()
Unbind disconnects any configured data source from this List. The contents will return to what was displayed before binding. Upon unbinding all items will update.
2.8func (*List) Unselect
func (l *List) Unselect(id ListItemID)
Unselect removes the item identified by the given ID from the selection.
func (*List) UnselectAll
func (l *List) UnselectAll()
UnselectAll removes all items from the selection.
2.1