mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Merge pull request #728 from Textualize/invisible-widgets
exclude invisible widgets
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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})")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user