OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2022.2.4
Standard Standalone? (y/n) If not then what?: Yes
What are you trying to achieve?:
I have three pictures (cat, dog, pig) and want participant to click on any of the picture and a text of the object name will show up.
What did you try to make it work?:
Step 1: I uploaded three images and named them “cat”, “dog”, “pig”.
Step 2: added mouse component.
Step 3: created code component.
clickables = ['cat','dog','pig']
for clickable in clickables: if sum(mouse.getPressed()) == 0: object_name = "" if mouse.isPressedIn(clickable): object_name = clickable.name display.setPos(mouse.getPos() + 0.1)
created a text named “display”, which was also used in code to set its position.
The text Start condition is $mouse.isPressedIn(clickable)
Text is set to $object_name, which is defined in code.
What specifically went wrong when you tried that?:
Include pasted full error message if possible. “That didn’t work” is not enough information.
Unexpected behavior: Only when the last element in clickables list is clicked, which is “pig” in this case, the text will show. Then “cat” or “dog” will show when they are clicked after “pig”.
But if cat or dog is clicked first, the text won’t show. The text shows only when the last element of the clickable list is clicked.
To debug, I changed the display’s Text from a variable “$object_name” to a string. The same odd behavior occurred. Therefore, I conclude the display’s Start condition " $mouse.isPressedIn(clickable)" only triggers when the last element of clickables list is clicked.
My question may narrow down to How to set the display (text) Start condition that no matter which image is clicked, the Text content will show.
clickshow.psyexp (16.7 KB)