Skip to content

List

_This is the list class. It provides a scrollable list of selectable items with support for _ custom item rendering, separators, and selection handling.

Extends: Collection

Properties

PropertyTypeDefaultDescription
offsetnumber0Current scroll offset for viewing long lists
emptyTextstring"Noitems" Text to display when the list is empty
showScrollBarbooleantrueWhether to show the scrollbar when items exceed height
scrollBarSymbolstring"" Symbol used for the scrollbar handle
scrollBarBackgroundstring"\127"Symbol used for the scrollbar background
scrollBarColorcolorlightGrayColor of the scrollbar handle
scrollBarBackgroundColorcolorgrayBackground color of the scrollbar

Events

EventParametersDescription
onSelectList self, index number, item tableFired when an item is selected

Functions

MethodReturnsDescription
List:onSelectListRegisters a callback for the select event
List:scrollToBottomListScrolls the list to the bottom
List:scrollToTopListScrolls the list to the top
List:scrollToItemListScrolls to a specific item

List:onSelect(callback)

Registers a callback for the select event

Parameters

  • callback function The callback function to register

Returns

  • List self The List instance

Usage

lua
list:onSelect(function(index, item) print("Selected item:", index, item) end)

List:scrollToBottom()

Scrolls the list to the bottom

Returns

  • List self The List instance

List:scrollToTop()

Scrolls the list to the top

Returns

  • List self The List instance

List:scrollToItem(index)

Scrolls to make a specific item visible

Parameters

  • index number The index of the item to scroll to

Returns

  • List self The List instance

Usage

lua
list:scrollToItem(5)

Released under the MIT License.