Skip to content

Commit

Permalink
blur action
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Nov 11, 2024
1 parent 19b6dd8 commit f9f220d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

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

## [0.85.2] - 2024-11-02

Expand Down
5 changes: 1 addition & 4 deletions src/textual/demo/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ class WidgetsScreen(PageScreen):
}
"""

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

def compose(self) -> ComposeResult:
with lazy.Reveal(containers.VerticalScroll(can_focus=False)):
Expand All @@ -465,6 +465,3 @@ def compose(self) -> ComposeResult:
yield Logs()
yield Sparklines()
yield Footer()

def action_unfocus(self) -> None:
self.set_focus(None)
4 changes: 4 additions & 0 deletions src/textual/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,10 @@ def action_minimize(self) -> None:
"""Action to minimize the currently maximized widget."""
self.minimize()

def action_blur(self) -> None:
"""Action to remove focus (if set)."""
self.set_focus(None)

def _reset_focus(
self, widget: Widget, avoiding: list[Widget] | None = None
) -> None:
Expand Down

0 comments on commit f9f220d

Please sign in to comment.