How to restrict mouse to move only in a circle object

Hi Everyone,

I am running an experiment with a circle stimulus which I would like my participants to click on the circumference/arc of the circle. In this case, I want to restrict movement of the mouse within the confines of the circle, and the experiment continues only after the participants clicks on any part of the circle’s circumference.
I generated the below code to only take mouse clicks that happen on the circle’s circumference but it seems I am doing the wrong thing given the error feedback received. I have set the end routine on press to only valid click

if mouse.getPressed()[0] and circle.edges.contains(mouse):
continueRoutine = False

AttributeError: ‘int’ object has no attribute ‘contains’

Regarding the confinement of mouse movement within the circle, I do not even know where to start.
I will be very happy to get help from here.

Thank you in advance.

How about an object (such as a small circular polygon) that has a position of the closest point on the circle to the mouse position. You could end the routine when the object is clicked

Thank you Wakecarter for your suggested solution. This means I would have to create several small circle polygons to fill up the circumference since a click on point on the circumference is correct.

However, this is what I have done.

resp_postion = [(colors_pos_rand[j][0][0] + ((circle_size[0] / 2) * sin(theta))), (colors_pos_rand[j][0][1] + ((circle_size[0] / 2) * cos(theta)))]

The variable response position refers to any position on the circumference the participant can click. So I put in the below code and I get error feedback

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

if mouse.getPressed()[0] and mouse.getPos()[0] == prac1_dot_pos_resp1:
continueRoutine = False