fix for table clicks

This commit is contained in:
Will McGugan
2022-10-08 13:12:38 +01:00
parent 9d24a3ad8f
commit cf438a5943
3 changed files with 13 additions and 11 deletions

View File

@@ -519,9 +519,10 @@ class Compositor:
"""
contains = Region.contains
for widget, cropped_region, region in self.layers_visible[y]:
if contains(cropped_region, x, y) and widget.visible:
return widget, region
if len(self.layers_visible) > y >= 0:
for widget, cropped_region, region in self.layers_visible[y]:
if contains(cropped_region, x, y) and widget.visible:
return widget, region
raise errors.NoWidget(f"No widget under screen coordinate ({x}, {y})")
def get_widgets_at(self, x: int, y: int) -> Iterable[tuple[Widget, Region]]:

View File

@@ -76,7 +76,7 @@ class ScrollView(Widget):
self._size = size
virtual_size = self.virtual_size
self._scroll_update(virtual_size)
self._container_size = size - self.gutter.totals
self._container_size = size
self.scroll_to(self.scroll_x, self.scroll_y, animate=False)
self.refresh()

View File

@@ -1680,21 +1680,22 @@ class Widget(DOMNode):
return lines
def get_style_at(self, x: int, y: int) -> Style:
"""Get the Rich style at a given screen offset.
"""Get the Rich style in a widget at a given relative offset.
Args:
x (int): X coordinate relative to the screen.
y (int): Y coordinate relative to the screen.
x (int): X coordinate relative to the widget.
y (int): Y coordinate relative to the widget.
Returns:
Style: A rich Style object.
"""
widget, region = self.screen.get_widget_at(x, y)
offset = Offset(x, y)
screen_offset = offset + self.region.offset
widget, _ = self.screen.get_widget_at(*screen_offset)
if widget is not self:
return Style()
offset_x, offset_y = region.offset
# offset_x, offset_y = self.screen.get_offset(self)
return self.screen.get_style_at(x + offset_x, y + offset_y)
return self.screen.get_style_at(*screen_offset)
async def _forward_event(self, event: events.Event) -> None:
event._set_forwarded()