Skip to content

Commit f9f220d

Browse files
committed
blur action
1 parent 19b6dd8 commit f9f220d

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515

1616
- Added `can_focus` and `can_focus_children` parameters to scrollable container types. https://github.com/Textualize/textual/pull/5226
1717
- Added `textual.lazy.Reveal` https://github.com/Textualize/textual/pull/5226
18+
- Added `Screen.action_blur` https://github.com/Textualize/textual/pull/5226
1819

1920
## [0.85.2] - 2024-11-02
2021

src/textual/demo/widgets.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ class WidgetsScreen(PageScreen):
452452
}
453453
"""
454454

455-
BINDINGS = [Binding("escape", "unfocus", "Unfocus any focused widget", show=False)]
455+
BINDINGS = [Binding("escape", "blur", "Unfocus any focused widget", show=False)]
456456

457457
def compose(self) -> ComposeResult:
458458
with lazy.Reveal(containers.VerticalScroll(can_focus=False)):
@@ -465,6 +465,3 @@ def compose(self) -> ComposeResult:
465465
yield Logs()
466466
yield Sparklines()
467467
yield Footer()
468-
469-
def action_unfocus(self) -> None:
470-
self.set_focus(None)

src/textual/screen.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,10 @@ def action_minimize(self) -> None:
780780
"""Action to minimize the currently maximized widget."""
781781
self.minimize()
782782

783+
def action_blur(self) -> None:
784+
"""Action to remove focus (if set)."""
785+
self.set_focus(None)
786+
783787
def _reset_focus(
784788
self, widget: Widget, avoiding: list[Widget] | None = None
785789
) -> None:

0 commit comments

Comments
 (0)