mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
swap order
This commit is contained in:
@@ -327,7 +327,7 @@ class App(Generic[ReturnType], DOMNode):
|
|||||||
screen and app are merged and returned."""
|
screen and app are merged and returned."""
|
||||||
|
|
||||||
namespace_binding_map: dict[str, tuple[DOMNode, Binding]] = {}
|
namespace_binding_map: dict[str, tuple[DOMNode, Binding]] = {}
|
||||||
for namespace, bindings in self._binding_chain:
|
for namespace, bindings in reversed(self._binding_chain):
|
||||||
for key, binding in bindings.keys.items():
|
for key, binding in bindings.keys.items():
|
||||||
namespace_binding_map[key] = (namespace, binding)
|
namespace_binding_map[key] = (namespace, binding)
|
||||||
|
|
||||||
@@ -1265,8 +1265,8 @@ class App(Generic[ReturnType], DOMNode):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def _binding_chain(self) -> list[tuple[DOMNode, Bindings]]:
|
def _binding_chain(self) -> list[tuple[DOMNode, Bindings]]:
|
||||||
"""Get a chain of nodes and bindings to consider. Goes from app to focused
|
"""Get a chain of nodes and bindings to consider. Goes from focused widget to app, or
|
||||||
widget, or app to screen.
|
screen to app.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[tuple[DOMNode, Bindings]]: List of DOM nodes and their bindings.
|
list[tuple[DOMNode, Bindings]]: List of DOM nodes and their bindings.
|
||||||
@@ -1275,13 +1275,11 @@ class App(Generic[ReturnType], DOMNode):
|
|||||||
namespace_bindings: list[tuple[DOMNode, Bindings]]
|
namespace_bindings: list[tuple[DOMNode, Bindings]]
|
||||||
if focused is None:
|
if focused is None:
|
||||||
namespace_bindings = [
|
namespace_bindings = [
|
||||||
(self, self._bindings),
|
|
||||||
(self.screen, self.screen._bindings),
|
(self.screen, self.screen._bindings),
|
||||||
|
(self, self._bindings),
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
namespace_bindings = [
|
namespace_bindings = [(node, node._bindings) for node in focused.ancestors]
|
||||||
(node, node._bindings) for node in reversed(focused.ancestors)
|
|
||||||
]
|
|
||||||
return namespace_bindings
|
return namespace_bindings
|
||||||
|
|
||||||
async def check_bindings(self, key: str) -> bool:
|
async def check_bindings(self, key: str) -> bool:
|
||||||
@@ -1294,7 +1292,7 @@ class App(Generic[ReturnType], DOMNode):
|
|||||||
bool: True if the key was handled by a binding, otherwise False
|
bool: True if the key was handled by a binding, otherwise False
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for namespace, bindings in reversed(self._binding_chain):
|
for namespace, bindings in self._binding_chain:
|
||||||
binding = bindings.keys.get(key)
|
binding = bindings.keys.get(key)
|
||||||
if binding is not None:
|
if binding is not None:
|
||||||
await self.action(binding.action, default_namespace=namespace)
|
await self.action(binding.action, default_namespace=namespace)
|
||||||
|
|||||||
Reference in New Issue
Block a user