From e537125baab4f1911f40038e68c73ecd79d7575a Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Fri, 1 Dec 2023 11:50:46 +0000 Subject: [PATCH] Catch no widget (#3790) * Catch no widget * changelog * version bump * remove prints --- CHANGELOG.md | 9 ++++++++- pyproject.toml | 2 +- src/textual/app.py | 22 +++++++++++++--------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aaf784b250..bfcf26d863 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` @@ -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 @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 031bdeeb58..5ee266d714 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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/" diff --git a/src/textual/app.py b/src/textual/app.py index edd228b3fe..cce4ad45ec 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -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(): @@ -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) @@ -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):