mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user