Skip to content
FutureBlitz

    Install

    Import std.term.views

    ListView

    std.term.views

    class

    Public Class ListView

    A list of Items, one of which is Selected, which Draw shows in a Region, scrolled to keep the selected one in view, with its Marker before it and drawn in SelectedLook, over ItemLook. HandleKey moves the selection with Up, Down, Page Up, Page Down, Home, and End, and HandleMouse with a click or the wheel.

    Examples

    Local list = ListView(["one", "two", "three"])
    list.HandleKey(KeyEvent(KeyCode.DOWN))
    Expect(list.Selected == 1 && list.SelectedItem == "two")

    std/term/views.fb, line 271

    • Public Field Items: String[] field #

      Its items, in order.

    • Public Field Marker: String field #

      What's before the selected item, with as many spaces before each other one.

    • Public Field ItemLook: Style field #

      How the items look.

    • Public Field SelectedLook: Style field #

      How the selected item looks.

    • Public New(items: String[]) constructor #

      A list of items, the first selected.

    • Public Property Selected: Int property #

      Which item is selected, from 0, or -1 for an empty list. Setting it keeps it in the list.

    • Public Property SelectedItem: String? property #

      The selected item, or Null for an empty list.

    • Public Method HandleKey(key: KeyEvent): Bool method #

      Moves the selection as key says, and gives whether it was one of its keys, which an empty list has none of.

    • Public Method HandleMouse(mouse: MouseEvent, area: Region): Bool method #

      Selects the item a press of the left button in area is on, or moves the selection three items for the wheel, and gives whether it did.

    • Public Method HandleEvent(event: InputEvent, area: Region): Bool method #

      Takes a key or the mouse's event in area, and gives whether it took it.

    • Public Method Draw(canvas: Canvas, area: Region) method #

      Draws the items that fit in area, one a row, scrolled to keep the selected one in view.

    Report an issue with this page or with FutureBlitz on GitHub.