Add list view and docs

This commit is contained in:
Darren Burns
2022-11-08 17:15:24 +00:00
parent 17dc927ed1
commit 6042346779
5 changed files with 159 additions and 24 deletions

62
docs/widgets/list_view.md Normal file
View File

@@ -0,0 +1,62 @@
# List View
Displays a vertical list of widgets which can be highlighted and selected.
Supports keyboard navigation.
- [x] Focusable
- [x] Container
## Example
The example below shows an app with a simple `ListView`.
=== "Output"
```{.textual path="docs/examples/widgets/list_view.py"}
```
=== "list_view.py"
```python
--8<-- "docs/examples/widgets/list_view.py"
```
## Reactive Attributes
| Name | Type | Default | Description |
|---------|-------|---------|---------------------------------|
| `index` | `int` | `0` | The currently highlighted index |
## Messages
### Highlighted
The `ListView.Highlighted` message is emitted when the highlight changes.
This happens when you use the arrow keys on your keyboard and when you
click on a list item.
- [x] Bubbles
#### Attributes
| attribute | type | purpose |
|-----------|------------|--------------------------------|
| `item` | `ListItem` | The item that was highlighted. |
### Selected
The `ListView.Selected` message is emitted when a list item is selected.
You can select a list item by pressing ++enter++ while it is highlighted,
or by clicking on it.
- [x] Bubbles
#### Attributes
| attribute | type | purpose |
|-----------|------------|-----------------------------|
| `item` | `ListItem` | The item that was selected. |
## See Also
* [ListView](../api/list_view.md) code reference