Some docstrings for actions (#2172)

This commit is contained in:
darrenburns
2023-03-30 10:18:19 +01:00
committed by GitHub
parent 2cd8295325
commit b0656fd606
2 changed files with 22 additions and 0 deletions

View File

@@ -2375,18 +2375,36 @@ class App(Generic[ReturnType], DOMNode):
self.pop_screen()
async def action_back(self) -> None:
"""Go back to the previous screen (pop the current screen)."""
try:
self.pop_screen()
except ScreenStackError:
pass
async def action_add_class_(self, selector: str, class_name: str) -> None:
"""Add a CSS class on the selected widget.
Args:
selector: Selects the widget to add the class to.
class_name: The class to add to the selected widget.
"""
self.screen.query(selector).add_class(class_name)
async def action_remove_class_(self, selector: str, class_name: str) -> None:
"""Remove a CSS class on the selected widget.
Args:
selector: Selects the widget to remove the class from.
class_name: The class to remove from the selected widget."""
self.screen.query(selector).remove_class(class_name)
async def action_toggle_class(self, selector: str, class_name: str) -> None:
"""Toggle a CSS class on the selected widget.
Args:
selector: Selects the widget to toggle the class on.
class_name: The class to toggle on the selected widget.
"""
self.screen.query(selector).toggle_class(class_name)
def action_focus_next(self) -> None:

View File

@@ -298,17 +298,21 @@ class ScrollBar(Widget):
self.mouse_over = False
def action_scroll_down(self) -> None:
"""Scroll vertical scrollbars down, horizontal scrollbars right."""
if not self.grabbed:
self.post_message(ScrollDown() if self.vertical else ScrollRight())
def action_scroll_up(self) -> None:
"""Scroll vertical scrollbars up, horizontal scrollbars left."""
if not self.grabbed:
self.post_message(ScrollUp() if self.vertical else ScrollLeft())
def action_grab(self) -> None:
"""Begin capturing the mouse cursor."""
self.capture_mouse()
def action_released(self) -> None:
"""Finish capturing the mouse cursor"""
self.capture_mouse(False)
async def _on_mouse_up(self, event: events.MouseUp) -> None: