From 563ccb8f0c3d70568c0c5e3a17559eb8a504bd85 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Mon, 9 Sep 2024 17:32:29 +0100 Subject: [PATCH] enable app focus styles --- src/textual/app.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/textual/app.py b/src/textual/app.py index 8f3fe1089c..81ef895e95 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -321,6 +321,9 @@ class App(Generic[ReturnType], DOMNode): dock: initial !important; } } + &:blur Screen Widget{ + tint: $panel 50%; + } } *:disabled:can-focus { opacity: 0.7; @@ -820,6 +823,20 @@ def _context(self) -> Generator[None, None, None]: active_message_pump.reset(message_pump_reset_token) active_app.reset(app_reset_token) + def get_pseudo_classes(self) -> Iterable[str]: + """Pseudo classes for a widget. + + Returns: + Names of the pseudo classes. + """ + if self.app_focus: + yield "focus" + else: + yield "blur" + yield "dark" if self.app.dark else "light" + if self.is_inline: + yield "inline" + def animate( self, attribute: str, @@ -3608,6 +3625,7 @@ def post_mount() -> None: def _watch_app_focus(self, focus: bool) -> None: """Respond to changes in app focus.""" + self.screen._update_styles() if focus: # If we've got a last-focused widget, if it still has a screen, # and if the screen is still the current screen and if nothing