Skip to content

Commit

Permalink
add app to active message pump (#2071)
Browse files Browse the repository at this point in the history
* add app to active message pump

* made sender private

* changelog
  • Loading branch information
willmcgugan authored Mar 16, 2023
1 parent 43253f5 commit a404ee5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Dropped "loading-indicator--dot" component style from LoadingIndicator https://github.com/Textualize/textual/pull/2050

### Removed

- Removed `sender` attribute from messages. It's now just private (`_sender`). https://github.com/Textualize/textual/pull/2071

### Fixed

- Fixed borders not rendering correctly. https://github.com/Textualize/textual/pull/2074


### Changed

- Breaking change: changed default behaviour of `Vertical` (see `VerticalScroll`) https://github.com/Textualize/textual/issues/1957
Expand Down
4 changes: 3 additions & 1 deletion src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from ._asyncio import create_task
from ._callback import invoke
from ._compose import compose
from ._context import active_app
from ._context import active_app, active_message_pump
from ._event_broker import NoHandler, extract_handler_actions
from ._path import _make_path_object_relative
from ._wait import wait_for_idle
Expand Down Expand Up @@ -918,6 +918,7 @@ async def run_app(app) -> None:
)

# Launch the app in the "background"
active_message_pump.set(app)
app_task = create_task(run_app(app), name=f"run_test {app}")

# Wait until the app has performed all startup routines.
Expand Down Expand Up @@ -973,6 +974,7 @@ async def run_auto_pilot(
raise

pilot = Pilot(app)
active_message_pump.set(self)
auto_pilot_task = create_task(
run_auto_pilot(auto_pilot, pilot), name=repr(pilot)
)
Expand Down
1 change: 1 addition & 0 deletions src/textual/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def send_event(self, event: events.Event) -> None:

def process_event(self, event: events.Event) -> None:
"""Performs some additional processing of events."""
event._set_sender(self._target)
if isinstance(event, events.MouseDown):
self._mouse_down_time = event.time
if event.button:
Expand Down
6 changes: 0 additions & 6 deletions src/textual/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ def __init_subclass__(
if namespace is not None:
cls.namespace = namespace

@property
def sender(self) -> MessageTarget:
"""The sender of the message."""
assert self._sender is not None
return self._sender

@property
def is_forwarded(self) -> bool:
return self._forwarded
Expand Down

0 comments on commit a404ee5

Please sign in to comment.