mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
dispatch kehy
This commit is contained in:
@@ -18,9 +18,5 @@ class BasicApp(App):
|
|||||||
sidebar=Widget(),
|
sidebar=Widget(),
|
||||||
)
|
)
|
||||||
|
|
||||||
# # self.app.panic(self["#sidebar"].styles.has_rule("border"))
|
|
||||||
|
|
||||||
# self.app.panic(repr(self["#sidebar"]._inline_styles.border))
|
|
||||||
|
|
||||||
|
|
||||||
BasicApp.run(css_file="basic.css", watch_css=True, log="textual.log")
|
BasicApp.run(css_file="basic.css", watch_css=True, log="textual.log")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from textual.app import App
|
from textual.app import App
|
||||||
|
from textual import events
|
||||||
from textual.widgets import Placeholder
|
from textual.widgets import Placeholder
|
||||||
from textual.widget import Widget
|
from textual.widget import Widget
|
||||||
from textual import events
|
|
||||||
|
|
||||||
|
|
||||||
class BasicApp(App):
|
class BasicApp(App):
|
||||||
@@ -16,6 +16,9 @@ class BasicApp(App):
|
|||||||
sidebar=Widget(),
|
sidebar=Widget(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def on_key(self, event: events.Key) -> None:
|
||||||
|
await self.dispatch_key(event)
|
||||||
|
|
||||||
def key_a(self) -> None:
|
def key_a(self) -> None:
|
||||||
self.query("#footer").set_styles(text="on magenta")
|
self.query("#footer").set_styles(text="on magenta")
|
||||||
|
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ class DockProperty:
|
|||||||
Returns:
|
Returns:
|
||||||
str: The dock name as a string, or "" if the rule is not set.
|
str: The dock name as a string, or "" if the rule is not set.
|
||||||
"""
|
"""
|
||||||
return obj._rules.get("dock") or ""
|
return obj._rules.get("dock") or "_default"
|
||||||
|
|
||||||
def __set__(self, obj: Styles, spacing: str | None):
|
def __set__(self, obj: Styles, spacing: str | None):
|
||||||
"""Set the Dock property
|
"""Set the Dock property
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ class MessagePump:
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def dispatch_key(self, event: events.Key) -> bool:
|
async def dispatch_key(self, event: events.Key) -> None:
|
||||||
"""Dispatch a key event to method.
|
"""Dispatch a key event to method.
|
||||||
|
|
||||||
This method will call the method named 'key_<event.key>' if it exists. This key method
|
This method will call the method named 'key_<event.key>' if it exists. This key method
|
||||||
@@ -324,8 +324,7 @@ class MessagePump:
|
|||||||
key_method = getattr(self, f"key_{event.key}", None)
|
key_method = getattr(self, f"key_{event.key}", None)
|
||||||
if key_method is not None:
|
if key_method is not None:
|
||||||
await invoke(key_method, event)
|
await invoke(key_method, event)
|
||||||
return True
|
event.prevent_default()
|
||||||
return False
|
|
||||||
|
|
||||||
async def on_timer(self, event: events.Timer) -> None:
|
async def on_timer(self, event: events.Timer) -> None:
|
||||||
event.prevent_default()
|
event.prevent_default()
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class View(Widget):
|
|||||||
|
|
||||||
DEFAULT_STYLES = """
|
DEFAULT_STYLES = """
|
||||||
layout: dock;
|
layout: dock;
|
||||||
|
docks: _default=top;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name: str | None = None, id: str | None = None) -> None:
|
def __init__(self, name: str | None = None, id: str | None = None) -> None:
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class Widget(DOMNode):
|
|||||||
can_focus: bool = False
|
can_focus: bool = False
|
||||||
|
|
||||||
DEFAULT_STYLES = """
|
DEFAULT_STYLES = """
|
||||||
dock: _default;
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name: str | None = None, id: str | None = None) -> None:
|
def __init__(self, name: str | None = None, id: str | None = None) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user