Skip to content

Commit

Permalink
enable app focus styles
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Sep 9, 2024
1 parent cfa093e commit 563ccb8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ class App(Generic[ReturnType], DOMNode):
dock: initial !important;
}
}
&:blur Screen Widget{
tint: $panel 50%;
}
}
*:disabled:can-focus {
opacity: 0.7;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 563ccb8

Please sign in to comment.