Change emit to post to self.

This commit is contained in:
Rodrigo Girão Serrão 2023-02-07 17:59:57 +00:00
parent a6d7747f28
commit d3e66721e9
2 changed files with 5 additions and 10 deletions

View file

@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Breaking change: `TreeNode` can no longer be imported from `textual.widgets`; it is now available via `from textual.widgets.tree import TreeNode`. https://github.com/Textualize/textual/pull/1637
- `Tree` now shows a (subdued) cursor for a highlighted node when focus has moved elsewhere https://github.com/Textualize/textual/issues/1471
- `MessagePump.emit` and `MessagePump.emit_no_wait` now emit events to self instead of to the parent
### Fixed

View file

@ -581,7 +581,7 @@ class MessagePump(metaclass=MessagePumpMeta):
await invoke(event.callback)
def emit_no_wait(self, message: Message) -> bool:
"""Send a message to the _parent_, non async version.
"""Send a message to self, non-async version.
Args:
message: A message object.
@ -589,13 +589,10 @@ class MessagePump(metaclass=MessagePumpMeta):
Returns:
True if the message was posted successfully.
"""
if self._parent:
return self._parent._post_message_from_child_no_wait(message)
else:
return False
return self.post_message_no_wait(message)
async def emit(self, message: Message) -> bool:
"""Send a message to the _parent_.
"""Send a message to self.
Args:
message: A message object.
@ -603,10 +600,7 @@ class MessagePump(metaclass=MessagePumpMeta):
Returns:
True if the message was posted successfully.
"""
if self._parent:
return await self._parent._post_message_from_child(message)
else:
return False
return await self.post_message(message)
# TODO: Does dispatch_key belong on message pump?
async def dispatch_key(self, event: events.Key) -> bool: