More documentation for Input widget

This commit is contained in:
Darren Burns
2022-10-04 17:05:57 +01:00
parent ad610e61cd
commit ce58e3e3e3
15 changed files with 87 additions and 10 deletions

View File

@@ -8,7 +8,7 @@ The `Click` event is sent to a widget when the user clicks a mouse button.
## Attributes ## Attributes
| attribute | type | purpose | | attribute | type | purpose |
| ---------- | ---- | ----------------------------------------- | |------------|------|-------------------------------------------|
| `x` | int | Mouse x coordinate, relative to Widget | | `x` | int | Mouse x coordinate, relative to Widget |
| `y` | int | Mouse y coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget |
| `delta_x` | int | Change in x since last mouse event | | `delta_x` | int | Change in x since last mouse event |

View File

@@ -8,7 +8,7 @@ The `MouseMove` event is sent to a widget when the mouse pointer is moved over a
## Attributes ## Attributes
| attribute | type | purpose | | attribute | type | purpose |
| ---------- | ---- | ----------------------------------------- | |------------|------|-------------------------------------------|
| `x` | int | Mouse x coordinate, relative to Widget | | `x` | int | Mouse x coordinate, relative to Widget |
| `y` | int | Mouse y coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget |
| `delta_x` | int | Change in x since last mouse event | | `delta_x` | int | Change in x since last mouse event |

View File

@@ -8,7 +8,7 @@ The `MouseRelease` event is sent to a widget when it is no longer receiving mous
## Attributes ## Attributes
| attribute | type | purpose | | attribute | type | purpose |
| ---------------- | ------ | --------------------------------------------- | |------------------|--------|-----------------------------------------------|
| `mouse_position` | Offset | Mouse coordinates when the mouse was released | | `mouse_position` | Offset | Mouse coordinates when the mouse was released |
## Code ## Code

View File

@@ -8,7 +8,7 @@ The `MouseScrollDown` event is sent to a widget when the scroll wheel (or trackp
## Attributes ## Attributes
| attribute | type | purpose | | attribute | type | purpose |
| --------- | ---- | -------------------------------------- | |-----------|------|----------------------------------------|
| `x` | int | Mouse x coordinate, relative to Widget | | `x` | int | Mouse x coordinate, relative to Widget |
| `y` | int | Mouse y coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget |

View File

@@ -8,7 +8,7 @@ The `MouseScrollUp` event is sent to a widget when the scroll wheel (or trackpad
## Attributes ## Attributes
| attribute | type | purpose | | attribute | type | purpose |
| --------- | ---- | -------------------------------------- | |-----------|------|----------------------------------------|
| `x` | int | Mouse x coordinate, relative to Widget | | `x` | int | Mouse x coordinate, relative to Widget |
| `y` | int | Mouse y coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget |

View File

@@ -8,7 +8,7 @@ The `MouseUp` event is sent to a widget when the user releases a mouse button.
## Attributes ## Attributes
| attribute | type | purpose | | attribute | type | purpose |
| ---------- | ---- | ----------------------------------------- | |------------|------|-------------------------------------------|
| `x` | int | Mouse x coordinate, relative to Widget | | `x` | int | Mouse x coordinate, relative to Widget |
| `y` | int | Mouse y coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget |
| `delta_x` | int | Change in x since last mouse event | | `delta_x` | int | Change in x since last mouse event |

View File

@@ -8,7 +8,7 @@ The `Paste` event is sent to a widget when the user pastes text.
## Attributes ## Attributes
| attribute | type | purpose | | attribute | type | purpose |
| --------- | ---- | ------------------------ | |-----------|------|--------------------------|
| `text` | str | The text that was pasted | | `text` | str | The text that was pasted |
## Code ## Code

View File

@@ -8,7 +8,7 @@ The `Resize` event is sent to a widget when its size changes and when it is firs
## Attributes ## Attributes
| attribute | type | purpose | | attribute | type | purpose |
| ---------------- | ---- | ------------------------------------------------ | |------------------|------|--------------------------------------------------|
| `size` | Size | The new size of the Widget | | `size` | Size | The new size of the Widget |
| `virtual_size` | Size | The virtual size (scrollable area) of the Widget | | `virtual_size` | Size | The virtual size (scrollable area) of the Widget |
| `container_size` | Size | The size of the container (parent widget) | | `container_size` | Size | The size of the container (parent widget) |

1
docs/reference/input.md Normal file
View File

@@ -0,0 +1 @@
::: textual.widgets.Input

View File

@@ -5,6 +5,9 @@
A simple footer widget which is docked to the bottom of its parent container. Displays A simple footer widget which is docked to the bottom of its parent container. Displays
available keybindings for the currently focused widget. available keybindings for the currently focused widget.
- [ ] Focusable
- [ ] Container
## Example ## Example
The example below shows an app with a single keybinding that contains only a `Footer` The example below shows an app with a single keybinding that contains only a `Footer`

View File

@@ -4,6 +4,9 @@
A simple header widget which docks itself to the top of the parent container. A simple header widget which docks itself to the top of the parent container.
- [ ] Focusable
- [ ] Container
## Example ## Example
The example below shows an app with a `Header`. The example below shows an app with a `Header`.

68
docs/widgets/input.md Normal file
View File

@@ -0,0 +1,68 @@
# Input
## Description
A single-line text input widget.
- [x] Focusable
- [ ] Container
## Example
The example below shows how you might create a simple form using two `Input` widgets.
=== "Output"
```{.textual path="docs/examples/widgets/input.py"}
```
=== "input.py"
```python
--8<-- "docs/examples/widgets/input.py"
```
## Reactive Attributes
| Name | Type | Default | Description |
|-------------------|--------|---------|-----------------------------------------------------------------|
| `cursor_blink` | `bool` | `True` | True if cursor blinking is enabled. |
| `value` | `str` | `""` | The value currently in the text input. |
| `cursor_position` | `int` | `0` | The index of the cursor in the value string. |
| `placeholder` | `str` | `str` | The dimmed placeholder text to display when the input is empty. |
| `password` | `bool` | `False` | True if the input should be masked. |
## Messages
### Changed
The `Input.Changed` message is sent when the value in the text input changes.
- [x] Bubbles
#### Attributes
| attribute | type | purpose |
|-----------|-------|----------------------------------|
| `value` | `str` | The new value in the text input. |
### Submitted
- [x] Bubbles
#### Attributes
| attribute | type | purpose |
|-----------|-------|----------------------------------|
| `value` | `str` | The new value in the text input. |
## Additional Notes
* The spacing around the text content is due to border. To remove it, set `border: none;` in your CSS.
*
## See Also
* [Input](../reference/input.md) code reference

View File

@@ -5,6 +5,9 @@
A widget which displays a static renderable content. A widget which displays a static renderable content.
Can be used for simple text labels, but can also contain more complex Rich renderables. Can be used for simple text labels, but can also contain more complex Rich renderables.
- [ ] Focusable
- [x] Container
## Example ## Example
The example below shows how you can use a `Static` widget as a simple text label. The example below shows how you can use a `Static` widget as a simple text label.

View File

@@ -1 +0,0 @@
# TextInput

View File

@@ -91,7 +91,7 @@ nav:
- "widgets/footer.md" - "widgets/footer.md"
- "widgets/header.md" - "widgets/header.md"
- "widgets/static.md" - "widgets/static.md"
- "widgets/text_input.md" - "widgets/input.md"
- "widgets/tree_control.md" - "widgets/tree_control.md"
- Reference: - Reference:
- "reference/app.md" - "reference/app.md"