This commit is contained in:
Will McGugan
2024-11-09 16:23:32 +00:00
parent e157c6b2b1
commit 7aa434a1af
3 changed files with 10 additions and 8 deletions

View File

@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- `Driver.process_event` is now `Driver.process_message` https://github.com/Textualize/textual/pull/5217
- `Driver.send_event` is now `Driver.send_message` https://github.com/Textualize/textual/pull/5217
## [0.85.2] - 2024-11-02

View File

@@ -1678,7 +1678,7 @@ class App(Generic[ReturnType], DOMNode):
char = key if len(key) == 1 else None
key_event = events.Key(key, char)
key_event.set_sender(app)
driver.send_event(key_event)
driver.send_message(key_event)
await wait_for_idle(0)
await app._animator.wait_until_complete()
await wait_for_idle(0)
@@ -4470,6 +4470,7 @@ class App(Generic[ReturnType], DOMNode):
self.log.debug(message)
def _on_idle(self) -> None:
"""Send app resize events on idle, so we don't do more resizing that necessary."""
event = self._resize_event
if event is not None:
self._resize_event = None

View File

@@ -64,21 +64,21 @@ class Driver(ABC):
"""Can this driver be suspended?"""
return False
def send_event(self, event: events.Event) -> None:
"""Send an event to the target app.
def send_message(self, message: messages.Message) -> None:
"""Send a message to the target app.
Args:
event: An event.
message: A message.
"""
asyncio.run_coroutine_threadsafe(
self._app._post_message(event), loop=self._loop
self._app._post_message(message), loop=self._loop
)
def process_message(self, message: messages.Message) -> None:
"""Perform additional processing on a message, prior to sending.
Args:
event: An event to send.
event: A message to process.
"""
# NOTE: This runs in a thread.
# Avoid calling methods on the app.
@@ -111,7 +111,7 @@ class Driver(ABC):
self._down_buttons.clear()
move_event = self._last_move_event
for button in buttons:
self.send_event(
self.send_message(
MouseUp(
x=move_event.x,
y=move_event.y,
@@ -128,7 +128,7 @@ class Driver(ABC):
)
self._last_move_event = message
self.send_event(message)
self.send_message(message)
@abstractmethod
def write(self, data: str) -> None: