binding tweak

This commit is contained in:
Will McGugan
2023-04-01 18:48:03 +01:00
parent b48178b80d
commit 11c3790eba
2 changed files with 8 additions and 6 deletions

View File

@@ -279,11 +279,7 @@ class App(Generic[ReturnType], DOMNode):
also the `sub_title` attribute. also the `sub_title` attribute.
""" """
BINDINGS = [ BINDINGS = [Binding("ctrl+c", "quit", "Quit", show=False, priority=True)]
Binding("ctrl+c", "quit", "Quit", show=False, priority=True),
Binding("tab", "focus_next", "Focus Next", show=False),
Binding("shift+tab", "focus_previous", "Focus Previous", show=False),
]
title: Reactive[str] = Reactive("", compute=False) title: Reactive[str] = Reactive("", compute=False)
sub_title: Reactive[str] = Reactive("", compute=False) sub_title: Reactive[str] = Reactive("", compute=False)
@@ -1984,7 +1980,7 @@ class App(Generic[ReturnType], DOMNode):
def _modal_binding_chain(self) -> list[tuple[DOMNode, Bindings]]: def _modal_binding_chain(self) -> list[tuple[DOMNode, Bindings]]:
"""The binding chain, ignoring everything before the last modal.""" """The binding chain, ignoring everything before the last modal."""
binding_chain = self._binding_chain binding_chain = self._binding_chain
for index, (node, _bindings) in enumerate(binding_chain): for index, (node, _bindings) in enumerate(binding_chain, 1):
if node.is_modal: if node.is_modal:
return binding_chain[:index] return binding_chain[:index]
return binding_chain return binding_chain

View File

@@ -11,6 +11,7 @@ from ._callback import invoke
from ._compositor import Compositor, MapGeometry from ._compositor import Compositor, MapGeometry
from ._context import visible_screen_stack from ._context import visible_screen_stack
from ._types import CallbackType from ._types import CallbackType
from .binding import Binding
from .css.match import match from .css.match import match
from .css.parse import parse_selectors from .css.parse import parse_selectors
from .css.query import QueryType from .css.query import QueryType
@@ -45,6 +46,11 @@ class Screen(Widget):
stack_updates: Reactive[int] = Reactive(0, repaint=False) stack_updates: Reactive[int] = Reactive(0, repaint=False)
"""An integer that updates when the screen is resumed.""" """An integer that updates when the screen is resumed."""
BINDINGS = [
Binding("tab", "focus_next", "Focus Next", show=False),
Binding("shift+tab", "focus_previous", "Focus Previous", show=False),
]
def __init__( def __init__(
self, self,
name: str | None = None, name: str | None = None,