| Reference | Downloads | Github

Mouse position set to (0,0), but every time appear at the up-right corner of screen

Hi, I’ve encountered this problem for mouse position. For each trial, I’d like the mouse to appear at the center of the screen when it’s time for participants to respond. However, with the code below, the mouse does appear at the right time but it’s always at the up-right corner of the screen. Can anyone help me with this?

Thank you!

I’m using Mac OS Mojave.

Below is my code:

    if t >= click_on:
        click = event.Mouse(visible=True, win=win)
        # check the list of shapes
        clicked = False
        #while not clicked:
        for i, choice in enumerate(choices):
            if click.isPressedIn(choices[i]): # click any object
                clicked = True
                response = i
                click_time = expClock.getTime()
                resp_time = click_time - click_on
                if response == sample_index:
                    correct_ans = 1
                elif response != sample_index:
                    correct_ans = 0
                continueRoutine = False
                win.mouseVisible = False
                break # exit this loop

I think you should move
click.setPos([0,0]) after clicked = False because now you set the position after you make the mouse invisible.

Hi thank you for the help. I did try put it after clicked = False, but it resulted in the mouse being invisible.

Does it work for you? The mouse appears at the right corner, then the mouse disappear, then it appear in the middle.

from psychopy import event, visual

win = visual.Window(units='pix',screen=1, color='white')
click = event.Mouse()
clicked = False
shape = visual.Circle(win=win, radius=30, pos=(20,20), fillColor= 'green', lineColor='red', units='pix')
click.setPos(newPos=(100, 100))

for i in range(0,100):

for i in range(0,100):
click.setPos(newPos=(0, 0))

while not clicked:
    if click.isPressedIn(shape):  # click any object
        clicked = True
        break  # exit this loop

If you still have problems, could you please post the script with all components and imports defined? It should not be your full experiment, just the part that you have problems with.