mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
exclude invisible widgets
This commit is contained in:
@@ -9,4 +9,5 @@ Static {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
margin: 2 4;
|
margin: 2 4;
|
||||||
min-width: 30;
|
min-width: 30;
|
||||||
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,14 @@ from textual.app import App
|
|||||||
from textual.widgets import Static
|
from textual.widgets import Static
|
||||||
|
|
||||||
|
|
||||||
|
class Clickable(Static):
|
||||||
|
def on_click(self):
|
||||||
|
self.app.bell()
|
||||||
|
|
||||||
|
|
||||||
class SpacingApp(App):
|
class SpacingApp(App):
|
||||||
def compose(self):
|
def compose(self):
|
||||||
yield Static()
|
yield Clickable()
|
||||||
|
|
||||||
|
|
||||||
app = SpacingApp(css_path="spacing.css")
|
app = SpacingApp(css_path="spacing.css")
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ class Compositor:
|
|||||||
# TODO: Optimize with some line based lookup
|
# TODO: Optimize with some line based lookup
|
||||||
contains = Region.contains
|
contains = Region.contains
|
||||||
for widget, cropped_region, region, *_ in self:
|
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
|
return widget, region
|
||||||
raise errors.NoWidget(f"No widget under screen coordinate ({x}, {y})")
|
raise errors.NoWidget(f"No widget under screen coordinate ({x}, {y})")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user