Coverage for src / lilbee / cli / tui / widgets / list_text_area.py: 100%
15 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-04-29 19:16 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-04-29 19:16 +0000
1"""TextArea subclass that posts a ``Blurred`` message on focus loss.
3Textual's built-in :class:`TextArea` only emits ``Changed`` and
4``SelectionChanged`` messages. The settings screen needs to save list-typed
5values on focus loss (same save-on-blur UX as :class:`Input`), so this
6subclass posts a dedicated ``Blurred`` message after the default blur
7handling runs.
8"""
10from __future__ import annotations
12from textual.events import Blur
13from textual.message import Message
14from textual.widgets import TextArea
17class ListTextArea(TextArea):
18 """TextArea that posts a ``Blurred`` message when focus leaves it."""
20 class Blurred(Message):
21 """Posted after focus leaves the :class:`ListTextArea`."""
23 def __init__(self, control: ListTextArea) -> None:
24 super().__init__()
25 self._control = control
27 @property
28 def control(self) -> ListTextArea:
29 """The widget that lost focus. Enables ``@on`` selector matching."""
30 return self._control
32 def _on_blur(self, event: Blur) -> None:
33 super()._on_blur(event)
34 self.post_message(self.Blurred(self))