StandardListView

Like ListView, but with a default delegate, and a model property which is a model of type ListViewItem.

Properties

  • current_item (in_out int): The index of the currently active item. _1 mean none is selected, which is the default
  • model (in [ListViewItem]): The model of items.
  • selection_mode (in SelectionMode): Defines the selection mode.
  • edit_item (in int): Defines the item that is can be edited.
  • has_focus (out bool): True if the list view has focus.
  • enabled (in bool): True if the list view is enabled.
  • drag_drop_enabled (in bool): If set to true drop event is enabled.

Functions

  • set_current_item(index: int): Sets the current item by the specified index and brings it into view.
  • bring_into_view(index: int): If the given item is outside of the current visible area the list view will be scrolled to ensure the item is visible.

Callbacks

  • current_item_changed(/* current_item */ int): Emitted when the current item has changed because the user modified it
  • item_pointer_event(/* index */ int, /* event */ PointerEvent, /* position */ Point): Emitted on any mouse pointer event similar to TouchArea. Arguments are item index associated with the event, the PointerEvent itself and the mouse position within the listview.
  • item_accepted(/* index */ int, /* text */ string): Emitted when the text of the item is edited and after the enter is pressed.
  • key_pressed(/* event */ KeyEvent): Emitted when there is a key press event on the list view.
  • drop_event(/* event */ DropEvent): Emitted when a row is dropped on an other row.

Example

import { StandardListView } from "@coop/lib.slint";

export component Example inherits Window {
    width: 150px;
    height: 150px;

    StandardListView {
        width: 150px;
        height: 150px;
        model: [ { text: "Blue"}, { text: "Red" }, { text: "Green" },
            { text: "Yellow" }, { text: "Black"}, { text: "White"},
            { text: "Magenta" }, { text: "Cyan" },
        ];
    }
}