How to use mouse click on button to end trial

OS (e.g. Win10): OS X 10.14.4
PsychoPy version (e.g. 1.84.x): 3.1.0
**Standard Standalone? (y)
What are you trying to achieve?:

I have a routine with 6 different radio buttons. I want to set it up such that subjects must make a selection on each of the radio buttons before they can proceed, and of course so that they can change their answer on a button before proceeding.
So I created the radio buttons with the slider component, and added a shapeStim as a button, and have a mouse element that has the shapeStim as a clickable object.
Now, I obviously cannot have the mouse element set to end Routine on valid click, because that would mean subjects could bypass answering the radio buttons.
I have a piece of code that keeps track of whether all 6 radio buttons have had sections, and that piece definitely works. But when I manually want to check whether the shapeStim has been clicked, it does not work.

What did you try to make it work?:

if responseChecker >=6 and button in mouse.clicked_name:
    continueRoutine = False

in the above code, responseChecker is a variable that increments each time one of the radio buttons is selected (and then removes from the list to be checked); ā€˜buttonā€™ is the name of the shapeStim, and ā€˜mouseā€™ is the name of the mouse component.
When I add print (mouse.clicked_name), I only get [], even when I click the button.
I also tried using gotValidClick, but that also always remains FALSE.

Any pointers would be massively appreciated

Thank you!

what about:

if responseChecker >= 6 and mouse.isPressedIn(button):
    continueRoutine = False

(and assuming that this code runs in the ā€œeach frameā€ tab.)

Har to say much else without seeing the rest of the code and where/when this code is executed relative to the rest.

1 Like

HI Michael,

Sorry about the delay in getting back to you ā€” I didnā€™t have time to test this.

Magic ā€” works exactly as needed!

Many thanks indeed!

Marc