Skipping the image to be touched as response

OS (e.g. Win10):
PsychoPy version (v2024.2.4):
What are you trying to achieve?:
I am running a touchscreen experiment on a convertible laptop. My goal is that during the instructions screen, the participant should be able to tap anywhere on the screen to move forward in the experiment. In my earlier version we used SPACE as a response to move forward in the experiment. In the current version I would like the participant to be able to tap anywhere on the screen or atleast on an image/text to move forward rather than using the SPACE button.

What did you try to make it work?:
I tried the following code:
Begin Routine tab

stimulus = welcome_image
mouse = wlcm_rsp
mouse.setPos(newPos=(0,0))
mouserec = mouse.getPos()

Each Frame tab

mouseloc = mouse.getPos()
if welcome_image.contains(mouse):
    mouserec = mouseloc
    mousetime= core.getTime()
    continueRoutine = False

What specifically went wrong when you tried that?:
The code is completely skipping the welcome_image and move forward to instructions1 routine in the experiment. There are no errors shown as such which could help me identify the problem.

Please help me identify the issue which might be causing the problem. I may be missing a very minute thing here.

Thanks

I can see three issues here.

  1. You appear to be using the component AND Each Frame code to end the routine. Online, I no longer use the contains method for touchscreens but it does seem to still be useful for local experiments.

  2. Your contains code is missing a check to see if the mouse has moved.

  3. Your contains code is missing a minimum response time.

I’m also not sure why you have

stimulus = welcome_image # You don't seem to use it
mouse = wlcm_rsp # I just have a mouse component called mouse in my first routine
mouse.setPos(newPos=(0,0)) # Do you need to move the pointer? If so, why not mouse.setPos([0,0]) ?

Here is my suggested Each Frame code

mouseloc = mouse.getPos()
if welcome_image.contains(mouse) and (mouseloc[0] != mouserec[0] or mouseloc[1] != mouserec[1]) and t > .3:
     mousetime= t
     continueRoutine = False
else:
     mouserec = mouseloc

Your suggested code worked properly.
Thank you for your help.