Merge pull request #728 from Textualize/invisible-widgets

exclude invisible widgets
This commit is contained in:
Will McGugan
2022-09-02 14:02:28 +01:00
committed by GitHub
2 changed files with 7 additions and 2 deletions

View File

@@ -2,9 +2,14 @@ from textual.app import App
from textual.widgets import Static
class Clickable(Static):
def on_click(self):
self.app.bell()
class SpacingApp(App):
def compose(self):
yield Static()
yield Clickable()
app = SpacingApp(css_path="spacing.css")

View File

@@ -487,7 +487,7 @@ class Compositor:
# TODO: Optimize with some line based lookup
contains = Region.contains
for widget, cropped_region, region, *_ in self:
if contains(cropped_region, x, y):
if contains(cropped_region, x, y) and widget.visible:
return widget, region
raise errors.NoWidget(f"No widget under screen coordinate ({x}, {y})")