diff --git a/docs/events/click.md b/docs/events/click.md index 5d1c80c68..8be36002f 100644 --- a/docs/events/click.md +++ b/docs/events/click.md @@ -8,7 +8,7 @@ The `Click` event is sent to a widget when the user clicks a mouse button. ## Attributes | attribute | type | purpose | -| ---------- | ---- | ----------------------------------------- | +|------------|------|-------------------------------------------| | `x` | int | Mouse x coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget | | `delta_x` | int | Change in x since last mouse event | diff --git a/docs/events/mouse_move.md b/docs/events/mouse_move.md index 42fb61389..12cdca5f9 100644 --- a/docs/events/mouse_move.md +++ b/docs/events/mouse_move.md @@ -8,7 +8,7 @@ The `MouseMove` event is sent to a widget when the mouse pointer is moved over a ## Attributes | attribute | type | purpose | -| ---------- | ---- | ----------------------------------------- | +|------------|------|-------------------------------------------| | `x` | int | Mouse x coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget | | `delta_x` | int | Change in x since last mouse event | diff --git a/docs/events/mouse_release.md b/docs/events/mouse_release.md index 5d0fb1eba..89d1fe4ed 100644 --- a/docs/events/mouse_release.md +++ b/docs/events/mouse_release.md @@ -8,7 +8,7 @@ The `MouseRelease` event is sent to a widget when it is no longer receiving mous ## Attributes | attribute | type | purpose | -| ---------------- | ------ | --------------------------------------------- | +|------------------|--------|-----------------------------------------------| | `mouse_position` | Offset | Mouse coordinates when the mouse was released | ## Code diff --git a/docs/events/mouse_scroll_down.md b/docs/events/mouse_scroll_down.md index 2808cbf24..7228cc0bb 100644 --- a/docs/events/mouse_scroll_down.md +++ b/docs/events/mouse_scroll_down.md @@ -8,7 +8,7 @@ The `MouseScrollDown` event is sent to a widget when the scroll wheel (or trackp ## Attributes | attribute | type | purpose | -| --------- | ---- | -------------------------------------- | +|-----------|------|----------------------------------------| | `x` | int | Mouse x coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget | diff --git a/docs/events/mouse_scroll_up.md b/docs/events/mouse_scroll_up.md index 8fbe19c78..2114b5f41 100644 --- a/docs/events/mouse_scroll_up.md +++ b/docs/events/mouse_scroll_up.md @@ -8,7 +8,7 @@ The `MouseScrollUp` event is sent to a widget when the scroll wheel (or trackpad ## Attributes | attribute | type | purpose | -| --------- | ---- | -------------------------------------- | +|-----------|------|----------------------------------------| | `x` | int | Mouse x coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget | diff --git a/docs/events/mouse_up.md b/docs/events/mouse_up.md index 9536089ed..5b965132e 100644 --- a/docs/events/mouse_up.md +++ b/docs/events/mouse_up.md @@ -8,7 +8,7 @@ The `MouseUp` event is sent to a widget when the user releases a mouse button. ## Attributes | attribute | type | purpose | -| ---------- | ---- | ----------------------------------------- | +|------------|------|-------------------------------------------| | `x` | int | Mouse x coordinate, relative to Widget | | `y` | int | Mouse y coordinate, relative to Widget | | `delta_x` | int | Change in x since last mouse event | diff --git a/docs/events/paste.md b/docs/events/paste.md index c9e051271..fdae43e5c 100644 --- a/docs/events/paste.md +++ b/docs/events/paste.md @@ -8,7 +8,7 @@ The `Paste` event is sent to a widget when the user pastes text. ## Attributes | attribute | type | purpose | -| --------- | ---- | ------------------------ | +|-----------|------|--------------------------| | `text` | str | The text that was pasted | ## Code diff --git a/docs/events/resize.md b/docs/events/resize.md index 87e0ae8ac..2ffe554af 100644 --- a/docs/events/resize.md +++ b/docs/events/resize.md @@ -8,7 +8,7 @@ The `Resize` event is sent to a widget when its size changes and when it is firs ## Attributes | attribute | type | purpose | -| ---------------- | ---- | ------------------------------------------------ | +|------------------|------|--------------------------------------------------| | `size` | Size | The new size of the Widget | | `virtual_size` | Size | The virtual size (scrollable area) of the Widget | | `container_size` | Size | The size of the container (parent widget) | diff --git a/docs/reference/input.md b/docs/reference/input.md new file mode 100644 index 000000000..259ea86f9 --- /dev/null +++ b/docs/reference/input.md @@ -0,0 +1 @@ +::: textual.widgets.Input diff --git a/docs/widgets/footer.md b/docs/widgets/footer.md index 55a9e1fa8..c733decb1 100644 --- a/docs/widgets/footer.md +++ b/docs/widgets/footer.md @@ -5,6 +5,9 @@ A simple footer widget which is docked to the bottom of its parent container. Displays available keybindings for the currently focused widget. +- [ ] Focusable +- [ ] Container + ## Example The example below shows an app with a single keybinding that contains only a `Footer` diff --git a/docs/widgets/header.md b/docs/widgets/header.md index 240d2dd52..b66e9f23c 100644 --- a/docs/widgets/header.md +++ b/docs/widgets/header.md @@ -4,6 +4,9 @@ A simple header widget which docks itself to the top of the parent container. +- [ ] Focusable +- [ ] Container + ## Example The example below shows an app with a `Header`. diff --git a/docs/widgets/input.md b/docs/widgets/input.md new file mode 100644 index 000000000..dde12dabf --- /dev/null +++ b/docs/widgets/input.md @@ -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 diff --git a/docs/widgets/static.md b/docs/widgets/static.md index e37d96110..27121bda7 100644 --- a/docs/widgets/static.md +++ b/docs/widgets/static.md @@ -5,6 +5,9 @@ A widget which displays a static renderable content. Can be used for simple text labels, but can also contain more complex Rich renderables. +- [ ] Focusable +- [x] Container + ## Example The example below shows how you can use a `Static` widget as a simple text label. diff --git a/docs/widgets/text_input.md b/docs/widgets/text_input.md deleted file mode 100644 index c55ce3dde..000000000 --- a/docs/widgets/text_input.md +++ /dev/null @@ -1 +0,0 @@ -# TextInput diff --git a/mkdocs.yml b/mkdocs.yml index 4ef376f2c..86e691c1d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -91,7 +91,7 @@ nav: - "widgets/footer.md" - "widgets/header.md" - "widgets/static.md" - - "widgets/text_input.md" + - "widgets/input.md" - "widgets/tree_control.md" - Reference: - "reference/app.md"