Keep a visible, but darker, cursor in Tree when it doesn't have focus

See #1471. It seems useful and important for a Tree to still have a cursor
visible even when it doesn't have focus -- that ways someone can build a UI
where the user can tab away from the tree to something that relates to the
node, and still see which node is in play.
This commit is contained in:
Dave Pearson
2023-01-31 15:51:31 +00:00
parent 4143bd7ee5
commit 6e1f18910a

View File

@@ -341,11 +341,15 @@ class Tree(Generic[TreeDataType], ScrollView, can_focus=True):
}
Tree > .tree--cursor {
background: $secondary;
background: $secondary-darken-2;
color: $text;
text-style: bold;
}
Tree:focus > .tree--cursor {
background: $secondary;
}
Tree > .tree--highlight {
text-style: underline;
}
@@ -925,7 +929,7 @@ class Tree(Generic[TreeDataType], ScrollView, can_focus=True):
label_style += self.get_component_rich_style(
"tree--highlight", partial=True
)
if self.cursor_line == y and self.has_focus:
if self.cursor_line == y:
label_style += self.get_component_rich_style(
"tree--cursor", partial=False
)