focus.go
1package list
2
3// FocusedRenderCallback is a helper function that returns a render callback
4// that marks items as focused during rendering.
5func FocusedRenderCallback(list *List) RenderCallback {
6 return func(idx, selectedIdx int, item Item) Item {
7 if focusable, ok := item.(Focusable); ok {
8 focusable.SetFocused(list.Focused() && idx == selectedIdx)
9 return focusable.(Item)
10 }
11 return item
12 }
13}