mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Merge pull request #2367 from davep/tidy-builtin-actions
Tidy builtin actions
This commit is contained in:
@@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- Breaking change: `Container` no longer shows required scrollbars by default https://github.com/Textualize/textual/issues/2361
|
||||
- Breaking change: `VerticalScroll` no longer shows a required horizontal scrollbar by default
|
||||
- Breaking change: `HorizontalScroll` no longer shows a required vertical scrollbar by default
|
||||
- Breaking change: Renamed `App.action_add_class_` to `App.action_add_class`
|
||||
- Breaking change: Renamed `App.action_remove_class_` to `App.action_remove_class`
|
||||
|
||||
### Added
|
||||
|
||||
|
||||
@@ -126,9 +126,18 @@ In the previous example if you wanted a link to set the background on the app ra
|
||||
|
||||
Textual supports the following builtin actions which are defined on the app.
|
||||
|
||||
- [action_add_class][textual.app.App.action_add_class]
|
||||
- [action_back][textual.app.App.action_back]
|
||||
- [action_bell][textual.app.App.action_bell]
|
||||
- [action_push_screen][textual.app.App.action_push_screen]
|
||||
- [action_check_bindings][textual.app.App.action_check_bindings]
|
||||
- [action_focus][textual.app.App.action_focus]
|
||||
- [action_focus_next][textual.app.App.action_focus_next]
|
||||
- [action_focus_previous][textual.app.App.action_focus_previous]
|
||||
- [action_pop_screen][textual.app.App.action_pop_screen]
|
||||
- [action_switch_screen][textual.app.App.action_switch_screen]
|
||||
- [action_push_screen][textual.app.App.action_push_screen]
|
||||
- [action_quit][textual.app.App.action_quit]
|
||||
- [action_remove_class][textual.app.App.action_remove_class]
|
||||
- [action_screenshot][textual.app.App.action_screenshot]
|
||||
- [action_switch_screen][textual.app.App.action_switch_screen]
|
||||
- [action_toggle_class][textual.app.App.action_toggle_class]
|
||||
- [action_toggle_dark][textual.app.App.action_toggle_dark]
|
||||
|
||||
@@ -2411,7 +2411,11 @@ class App(Generic[ReturnType], DOMNode):
|
||||
self._unregister(root)
|
||||
|
||||
async def action_check_bindings(self, key: str) -> None:
|
||||
"""An [action](/guide/actions) to handle a key press using the binding system."""
|
||||
"""An [action](/guide/actions) to handle a key press using the binding system.
|
||||
|
||||
Args:
|
||||
key: The key to process.
|
||||
"""
|
||||
if not await self.check_bindings(key, priority=True):
|
||||
await self.check_bindings(key, priority=False)
|
||||
|
||||
@@ -2458,13 +2462,19 @@ class App(Generic[ReturnType], DOMNode):
|
||||
self.pop_screen()
|
||||
|
||||
async def action_back(self) -> None:
|
||||
"""An [action](/guide/actions) to go back to the previous screen (pop the current screen)."""
|
||||
"""An [action](/guide/actions) to go back to the previous screen (pop the current screen).
|
||||
|
||||
Note:
|
||||
If there is no screen to go back to, this is a non-operation (in
|
||||
other words it's safe to call even if there are no other screens
|
||||
on the stack.)
|
||||
"""
|
||||
try:
|
||||
self.pop_screen()
|
||||
except ScreenStackError:
|
||||
pass
|
||||
|
||||
async def action_add_class_(self, selector: str, class_name: str) -> None:
|
||||
async def action_add_class(self, selector: str, class_name: str) -> None:
|
||||
"""An [action](/guide/actions) to add a CSS class to the selected widget.
|
||||
|
||||
Args:
|
||||
@@ -2473,7 +2483,7 @@ class App(Generic[ReturnType], DOMNode):
|
||||
"""
|
||||
self.screen.query(selector).add_class(class_name)
|
||||
|
||||
async def action_remove_class_(self, selector: str, class_name: str) -> None:
|
||||
async def action_remove_class(self, selector: str, class_name: str) -> None:
|
||||
"""An [action](/guide/actions) to remove a CSS class from the selected widget.
|
||||
|
||||
Args:
|
||||
|
||||
Reference in New Issue
Block a user