Add a focusable property

We want to maintain `can_focus` as "this is a thing that can, at some point,
receive focus, assuming it isn't disabled". So `can_focus` is now very much
about the ability to receive focus at all.

The new `focusable` property becomes about "can this widget receive focus
right now?".

[This is a rewording of a previous commit -- I get the wrong thing]
This commit is contained in:
Dave Pearson
2023-02-13 15:39:19 +00:00
parent 682c4de06d
commit 500458e5f3

View File

@@ -1177,6 +1177,11 @@ class Widget(DOMNode):
"""
return self.virtual_region.grow(self.styles.margin)
@property
def focusable(self) -> bool:
"""Can this widget currently receive focus?"""
return self.can_focus and not self.disabled
@property
def focusable_children(self) -> list[Widget]:
"""Get the children which may be focused.