Skip to content

Commit 6255f79

Browse files
authored
Fix #1999 (#2003)
1 parent 48146fb commit 6255f79

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

arcade/gui/widgets/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def move(self, dx: float = 0, dy: float = 0):
5959

6060
def collide_with_point(self, x, y):
6161
left, bottom, width, height = self
62-
return left < x < left + width and bottom < y < bottom + height
62+
return left <= x <= left + width and bottom <= y <= bottom + height
6363

6464
def scale(self, scale: float) -> "Rect":
6565
"""Returns a new rect with scale applied"""

tests/unit/gui/test_rect.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,12 @@ def test_rect_union():
166166

167167
# THEN
168168
assert new_rect == (0, 0, 20, 10)
169+
170+
171+
def test_collide_with_point():
172+
rect = Rect(0, 0, 100, 100)
173+
174+
assert rect.collide_with_point(0, 0)
175+
assert rect.collide_with_point(50, 50)
176+
assert rect.collide_with_point(100, 100)
177+
assert not rect.collide_with_point(150, 150)

0 commit comments

Comments
 (0)