ListView
A comprehensive list view with sorting, item management, and interaction features.
ListView provides a feature-rich interface for displaying and managing lists of data. It supports various operations including sorting, item selection, locking/unlocking, duplication, and deletion. The view uses a CollectionView internally for efficient scrolling and item recycling.
Features:
- Dynamic item lists with automatic updates
- Sortable items with drag-and-drop reordering
- Item selection with visual feedback
- Lock/unlock functionality for individual items
- Item duplication and deletion operations
- Two item height modes (small and large)
- Scroll control with optional scrollbar
- Theme integration and styling
- Event-driven architecture for item operations
- Integration with WindowItem for window management
Example usage:
var items = ["Item 1", "Item 2", "Item 3"];
var listView = new ListView(items);
listView.trashable = true;
listView.sortable = true;
listView.onTrashItem(this, (index) -> {
items.splice(index, 1);
});
Static Members
Standard height for small list items (30 pixels)
Standard height for large list items (39 pixels)
Instance Members
Default is false
, automatically set to true
when any of this instance's observable variables has changed.
The internal collection view that handles item display and scrolling
The data source providing item data to the collection view
Custom theme override for this list view
The array of items to display in the list
Index of the currently selected item (-1 for no selection)
Whether items can be deleted/trashed
Whether items can be locked/unlocked
Whether items can be duplicated
Whether items can be reordered via drag and drop
Whether to use small item height (30px) instead of large (39px)
Whether scrolling is enabled for the list
Optional WindowItem for window-specific list management. Used for coordinating list operations within a window context.
Whether to automatically check and update item locked states
Creates a new ListView instance.
Initializes the list view with the provided items array and sets up the internal collection view, data source, and automatic update handlers.
Name | Type | Description |
---|---|---|
items |
Array<Dynamic> | The initial array of items to display |
Private Members
Event when any observable value as changed on this instance.
Name | Type |
---|---|
instance |
ListView |
fromSerializedField |
Bool |
Emitted when an item should be moved above another item in the list
Name | Type |
---|---|
itemIndex |
Int |
otherItemIndex |
Int |
Emitted when an item should be moved below another item in the list
Name | Type |
---|---|
itemIndex |
Int |
otherItemIndex |
Int |
Emitted when an item should be deleted/trashed
Name | Type |
---|---|
itemIndex |
Int |
Emitted when an item should be locked
Name | Type |
---|---|
itemIndex |
Int |
Emitted when an item should be unlocked
Name | Type |
---|---|
itemIndex |
Int |
Emitted when an item should be duplicated
Name | Type |
---|---|
itemIndex |
Int |
Event when theme field changes.
Name | Type |
---|---|
current |
Theme |
previous |
Theme |
Event when items field changes.
Name | Type |
---|---|
current |
Array<Dynamic> |
previous |
Array<Dynamic> |
Event when selectedIndex field changes.
Name | Type |
---|---|
current |
Int |
previous |
Int |
Event when trashable field changes.
Name | Type |
---|---|
current |
Bool |
previous |
Bool |
Event when lockable field changes.
Name | Type |
---|---|
current |
Bool |
previous |
Bool |
Event when duplicable field changes.
Name | Type |
---|---|
current |
Bool |
previous |
Bool |
Event when sortable field changes.
Name | Type |
---|---|
current |
Bool |
previous |
Bool |
Event when smallItems field changes.
Name | Type |
---|---|
current |
Bool |
previous |
Bool |
Event when scrollEnabled field changes.
Name | Type |
---|---|
current |
Bool |
previous |
Bool |
Updates scroll behavior based on the scrollEnabled property.
Enables or disables scrolling and scrollbar visibility based on the current scrollEnabled setting.
Updates the collection view when items change.
Reloads the collection view data and ensures proper layout and scrolling when the items array or related properties change.
Overrides layout to properly size the collection view.
Ensures the collection view matches the size of this ListView.
Checks item locked states if auto-checking is enabled.
Called every frame to update locked states when autoCheckLocked is true.
Name | Type | Description |
---|---|---|
delta |
Float | Time elapsed since last frame |
Called after a lock item event is emitted.
Triggers a check of all item locked states to update the UI.
Name | Type | Description |
---|---|---|
itemIndex |
Int | The index of the item that was locked |
Called after an unlock item event is emitted.
Triggers a check of all item locked states to update the UI.
Name | Type | Description |
---|---|---|
itemIndex |
Int | The index of the item that was unlocked |
Checks and updates the locked state of all visible items.
Iterates through all visible cell views and updates their locked state based on the 'locked' property of their corresponding items. Automatically deselects any item that becomes locked.
Metadata
Name | Parameters |
---|---|
:build |
tracker.macros.ObservableMacro.build() |
:autoBuild |
tracker.macros.ObservableMacro.build() |
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |
:allow |
elements.ListViewDataSource |