From 257fe7b30ae62d661924a7bda9a5500700f2a031 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Mon, 13 Feb 2023 12:56:52 +0000 Subject: [PATCH] Add enabled and disabled pseudo-classes Note that this doesn't touch the application of stylesheets yet, in terms of things like specificity; this just makes sure that the classes exist and can be seen. --- docs/guide/CSS.md | 2 ++ src/textual/widget.py | 1 + 2 files changed, 3 insertions(+) diff --git a/docs/guide/CSS.md b/docs/guide/CSS.md index 80753ddbd..985c4b41f 100644 --- a/docs/guide/CSS.md +++ b/docs/guide/CSS.md @@ -315,6 +315,8 @@ The `background: green` is only applied to the Button underneath the mouse curso Here are some other pseudo classes: +- `:disabled` Matches widgets which are in a disabled state. +- `:enabled` Matches widgets which are in an enabled state. - `:focus` Matches widgets which have input focus. - `:focus-within` Matches widgets with a focused a child widget. diff --git a/src/textual/widget.py b/src/textual/widget.py index 53fe29983..5cb278389 100644 --- a/src/textual/widget.py +++ b/src/textual/widget.py @@ -2084,6 +2084,7 @@ class Widget(DOMNode): Names of the pseudo classes. """ + yield "disabled" if self.disabled else "enabled" if self.mouse_over: yield "hover" if self.has_focus: