Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch no widget #3790

Merged
merged 4 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased
## [0.44.0] - 2023-12-1

### Changed

- Breaking change: Dropped 3.7 support https://github.com/Textualize/textual/pull/3766
- Breaking changes https://github.com/Textualize/textual/issues/1530
- `link-hover-background` renamed to `link-background-hover`
- `link-hover-color` renamed to `link-color-hover`
Expand All @@ -20,6 +21,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added support for Ctrl+Fn and Ctrl+Shift+Fn keys in urxvt https://github.com/Textualize/textual/pull/3737
- Friendly error messages when trying to mount non-widgets https://github.com/Textualize/textual/pull/3780

### Fixed

- Fixed NoWidget when mouse goes outside window https://github.com/Textualize/textual/pull/3790
- Removed suprious print statements from press_keys https://github.com/Textualize/textual/issues/3785

## [0.43.2] - 2023-11-29

### Fixed
Expand Down Expand Up @@ -1488,6 +1494,7 @@ https://textual.textualize.io/blog/2022/11/08/version-040/#version-040
- New handler system for messages that doesn't require inheritance
- Improved traceback handling

[0.44.0]: https://github.com/Textualize/textual/compare/v0.43.2...v0.44.0
[0.43.2]: https://github.com/Textualize/textual/compare/v0.43.1...v0.43.2
[0.43.1]: https://github.com/Textualize/textual/compare/v0.43.0...v0.43.1
[0.43.0]: https://github.com/Textualize/textual/compare/v0.42.0...v0.43.0
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "textual"
version = "0.43.2"
version = "0.44.0"
homepage = "https://github.com/Textualize/textual"
repository = "https://github.com/Textualize/textual"
documentation = "https://textual.textualize.io/"
Expand Down
22 changes: 13 additions & 9 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,6 @@ async def _press_keys(self, keys: Iterable[str]) -> None:
for key in keys:
if key.startswith("wait:"):
_, wait_ms = key.split(":")
print(f"(pause {wait_ms}ms)")
await asyncio.sleep(float(wait_ms) / 1000)
else:
if len(key) == 1 and not key.isalnum():
Expand All @@ -1180,7 +1179,6 @@ async def _press_keys(self, keys: Iterable[str]) -> None:
char = unicodedata.lookup(_get_unicode_name_from_key(original_key))
except KeyError:
char = key if len(key) == 1 else None
print(f"press {key!r} (char={char!r})")
key_event = events.Key(key, char)
key_event._set_sender(app)
driver.send_event(key_event)
Expand Down Expand Up @@ -2698,13 +2696,19 @@ async def on_event(self, event: events.Event) -> None:

self.screen._forward_event(event)

if isinstance(event, events.MouseUp):
if self._mouse_down_widget is not None and (
self.get_widget_at(event.x, event.y)[0]
is self._mouse_down_widget
):
click_event = events.Click.from_event(event)
self.screen._forward_event(click_event)
if (
isinstance(event, events.MouseUp)
and self._mouse_down_widget is not None
):
try:
if (
self.get_widget_at(event.x, event.y)[0]
is self._mouse_down_widget
):
click_event = events.Click.from_event(event)
self.screen._forward_event(click_event)
except NoWidget:
pass

elif isinstance(event, events.Key):
if not await self.check_bindings(event.key, priority=True):
Expand Down
Loading