OS: Win10
PsychoPy version: 3.0.6
Standard Standalone? (y/n): yes
What are you trying to achieve?: Create several clickable text input fields within a same routine.
Hello!
I am trying to crate a kind of survey.
I display a question which has to be answered in a field. I used the following code component and a text component to display the answer:
Begin Routine
cursorCounter=0
cursorVariable='|'
captured_string=''
subject_response_finished=False
trial_clock=core.Clock()
Each frame
if cursorCounter >= 30:
if cursorVariable=='|':
cursorVariable=' '
else:
cursorVariable='|'
cursorCounter=0
cursorCounter+=1
if trial_clock.getTime() >= 1:
subject_response_finished=True
if subject_response_finished:
final_response=captured_string
for key in event.getKeys():
if key in ['escape']:
core.quit()
elif key in ['delete','backspace']:
captured_string = captured_string[:-1]
elif key in ['space']:
captured_string = captured_string+' '
elif key in ['lshift','rshift','up','down','left','right']:
pass
else:
captured_string = captured_string+key
End Routine
thisExp.addData('response',final_response)
(I wish I could cite the source of this code but I can’t find it…)
Then because I wanted a second input text field, I did the same within another code component and another text component, just changing the name of captured_string
, final_response
and subject_response_finished
It didn’t work. The second text component (where the second text input should appear) works at the same time as the first, and the characters that appears in the second text component are randomly selected from the typed sequence.
Then I added in Begin experiment mouse.isPressedIn(something)
so that the code understands that there are 2 different questions to answer. It didn’t work, my experiment won’t run.
I would be so glad if someone could help me!!! Thanks a lot in advance.
Oceane.