Added more documentation for the List primitive.

This commit is contained in:
Oliver 2023-03-25 21:22:23 +01:00
parent f38d14c988
commit 646df2bd7e
1 changed files with 20 additions and 3 deletions

23
list.go
View File

@ -15,7 +15,24 @@ type listItem struct {
Selected func() // The optional function which is called when the item is selected. Selected func() // The optional function which is called when the item is selected.
} }
// List displays rows of items, each of which can be selected. // List displays rows of items, each of which can be selected. List items can be
// shown as a single line or as two lines. They can be selected by pressing
// their assigned shortcut key, navigating to them and pressing Enter, or
// clicking on them with the mouse. The following key binds are available:
//
// - Down arrow / tab: Move down one item.
// - Up arrow / backtab: Move up one item.
// - Home: Move to the first item.
// - End: Move to the last item.
// - Page down: Move down one page.
// - Page up: Move up one page.
// - Enter / Space: Select the current item.
// - Right / left: Scroll horizontally. Only if the list is wider than the
// available space.
//
// See [List.SetChangedFunc] for a way to be notified when the user navigates
// to a list item. See [List.SetSelectedFunc] for a way to be notified when a
// list item was selected.
// //
// See https://github.com/rivo/tview/wiki/List for an example. // See https://github.com/rivo/tview/wiki/List for an example.
type List struct { type List struct {
@ -64,8 +81,8 @@ type List struct {
// of the right arrow key. // of the right arrow key.
overflowing bool overflowing bool
// An optional function which is called when the user has navigated to a list // An optional function which is called when the user has navigated to a
// item. // list item.
changed func(index int, mainText, secondaryText string, shortcut rune) changed func(index int, mainText, secondaryText string, shortcut rune)
// An optional function which is called when a list item was selected. This // An optional function which is called when a list item was selected. This