mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
docstrings
This commit is contained in:
@@ -239,6 +239,9 @@ class App(Generic[ReturnType], DOMNode):
|
|||||||
Args:
|
Args:
|
||||||
direction (int, optional): 1 to move forward, -1 to move backward, or
|
direction (int, optional): 1 to move forward, -1 to move backward, or
|
||||||
0 to highlight the current focus.
|
0 to highlight the current focus.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Widget | None: Newly focused widget, or None for no focus.
|
||||||
"""
|
"""
|
||||||
if self._focus_timer:
|
if self._focus_timer:
|
||||||
# Cancel the timer that clears the show focus class
|
# Cancel the timer that clears the show focus class
|
||||||
@@ -270,19 +273,36 @@ class App(Generic[ReturnType], DOMNode):
|
|||||||
return self.focused
|
return self.focused
|
||||||
|
|
||||||
def show_focus(self) -> Widget | None:
|
def show_focus(self) -> Widget | None:
|
||||||
"""Highlight the currently focused widget."""
|
"""Highlight the currently focused widget.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Widget | None: Focused widget, or None for no focus.
|
||||||
|
"""
|
||||||
return self._move_focus(0)
|
return self._move_focus(0)
|
||||||
|
|
||||||
def focus_next(self) -> Widget | None:
|
def focus_next(self) -> Widget | None:
|
||||||
"""Focus the next widget."""
|
"""Focus the next widget.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Widget | None: Newly focused widget, or None for no focus.
|
||||||
|
"""
|
||||||
return self._move_focus(1)
|
return self._move_focus(1)
|
||||||
|
|
||||||
def focus_previous(self) -> Widget | None:
|
def focus_previous(self) -> Widget | None:
|
||||||
"""Focus the previous widget."""
|
"""Focus the previous widget.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Widget | None: Newly focused widget, or None for no focus.
|
||||||
|
"""
|
||||||
return self._move_focus(-1)
|
return self._move_focus(-1)
|
||||||
|
|
||||||
def hide_focus(self) -> None:
|
def hide_focus(self) -> None:
|
||||||
"""Hide the focus."""
|
"""Hide the focus.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Widget | None: Newly focused widget, or None for no focus.
|
||||||
|
|
||||||
|
"""
|
||||||
self.remove_class("-show-focus")
|
self.remove_class("-show-focus")
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class NonFocusable(Widget, can_focus=False):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_focus_chain():
|
async def test_focus_chain():
|
||||||
|
|
||||||
app = App()
|
app = App()
|
||||||
app.push_screen(Screen())
|
app.push_screen(Screen())
|
||||||
@@ -31,7 +31,7 @@ def test_focus_chain():
|
|||||||
assert focused == ["foo", "Paul", "baz"]
|
assert focused == ["foo", "Paul", "baz"]
|
||||||
|
|
||||||
|
|
||||||
def test_show_focus():
|
async def test_show_focus():
|
||||||
app = App()
|
app = App()
|
||||||
app.push_screen(Screen())
|
app.push_screen(Screen())
|
||||||
app.screen.add_children(
|
app.screen.add_children(
|
||||||
@@ -51,7 +51,7 @@ def test_show_focus():
|
|||||||
assert app.has_class("-show-focus")
|
assert app.has_class("-show-focus")
|
||||||
|
|
||||||
|
|
||||||
def test_focus_next_and_previous():
|
async def test_focus_next_and_previous():
|
||||||
|
|
||||||
app = App()
|
app = App()
|
||||||
app.push_screen(Screen())
|
app.push_screen(Screen())
|
||||||
|
|||||||
Reference in New Issue
Block a user