Mouse click plus trial.finished=True doesn't work the first trial

OS : Win10
PsychoPy version : 2022.1.1
Standard Standalone? (y/n) : Yes
What are you trying to achieve?:
I want to end the loop using a button(beta)
What did you try to make it work?:
Here is the flow of my experiment. I put a button(beta) in the “working” routine and set it as follows:


endButton

What specifically went wrong when you tried that?:
In the first trial, it skips the “working” routine and jumps to the “mask” routine, and then ends the trial. However, starting from the second trial, it works totally fine. not jumping, no skipping.

I tried to insert another 'mask" between the “template” and “working” routine, then it worked fine from the first trial. In the “template” routine, I need to click on another button to go on to the next routine. So, my guess is that something carries on to the next routine? But I am not sure. And I can’t really put a mask between the two routines for my experiment.

Any suggestions on how to solve this? Thank you!

Is there a button in the template routine in the same screen location as the done shopping button in the working routine. If so, move one of them so you don’t get both pressed with one click.

No, the button in the template routine is in the middle, and the done shopping button is in the bottom left

Is there any way to check if the mouse is clicked at the start of the “working” routine and clear out any mouse pressing states if it is clicked?