Skip to content

Commit

Permalink
Catch no widget
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Dec 1, 2023
1 parent be8581e commit 2ff7dae
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2698,13 +2698,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

0 comments on commit 2ff7dae

Please sign in to comment.