MouseTrap: can't get mouse position to reset
Hi all,
I dread that this may be an amateur mistake on my part. ![]()
I'm using Mousetrap (Kieslich & Henninger, 2017) for a simple task but I want to hide the mouse in between responses. To do this, I added code in an inline_script during the run phase that looks like this:
# Hide the mouse my_mouse = mouse() my_mouse.show_cursor(show=False)
While that successfully hides my mouse, it no longer resets the mouse back to the proper origin (even though that option is properly clicked).

I tried manually repositioning the mouse by putting the following in the inline script
# Hide the mouse my_mouse = mouse() my_mouse.show_cursor(show=False) my_mouse.set_pos(pos=(0,350))
But this doesn't work either. The mouse is not repositioned at the start of get_response.
If I comment out my inline script, the mouse starts in the correct place but is now visible during the whole trial.
Can anyone explain why my mouse won't reset when hiding it?
Note: I'm using the legacy backend.

Comments
Hi Mike,
I tried out hiding the mouse in the mousetrap example experiment we provide online using your code. Interestingly, the problem does not occur if the experiment is run in window mode but it does occur if the experiment is run in fullscreen mode. I don't know where this difference comes from - maybe @sebastiaan has an idea?
I also found a solution for the problem: You have to insert another inline script directly before the get_response item. In the run phase of the inline script, you include the following code:
my_mouse.show_cursor(show=True)Then, the mouse is also reset in fullscreen mode (+ you don't need the code that explicitly resets the mouse using set_pos).
Best,
Pascal
Hi Pascal,
Thank you for the quick reply. The workaround functioned perfectly. Thank you so much for the helpful and speedy reply!
Hi both,
Thanks for this workaround! I was aware that PyGame (the underlying library) sometimes ignores mouse-position changes, but I don't know exactly why or when this happens either.
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!