Textbox displays previous response

OS (e.g. Win10): Mac 12.2.1
PsychoPy version (e.g. 1.84.x): 2022.2.4
Standard Standalone? (y/n) If not then what?: yes

I want to record responses using a textbox, but the last button response from the previous routine is recorded in the text box, despite not pressing a button during the trial that contained the textbox.

Previous posts suggested I set the textbox to editable and “set every repeat”, add textbox.text = "" to the Begin Routine tab of a code component, or change the order of the components within the routine, but these suggestions did not fix the issue. Pictures are attached below in case they help.

Any suggestions are appreciated!

Thanks,
Ted



In case it helps, I added a routine with a text component set for 100 ms before the routine that contained the textbox component and that seemed to resolve the issue.

If anyone has a better solution, let me know!

1 Like

Hello

did you try moving the code-component up. before the text-box?

Best wishes Jens

Jens,

I appreciate the response! I did try this, as it has worked with similar issues, but it was unsuccessful at fixing the issue.

Ted

I had the same problem, using PsychoPy v2021.2.3. When a routine containing an editable textbox followed a routine that elicited a keyboard response, the keyboard response was displayed in the textbox. It was not sufficient to add a code component with

myTextbox.text = ""

in the ‘Begin Routine’ tab because the textbox read responses from the keyboard buffer after the execution of this code. What worked for me was to clear the textbox again during the first few frames of the routine.

In the ‘Begin Routine’ tab:

myTextbox.text =""

frameNo = 0

In the ‘Each Frame’ tab:

if frameNo < 5:

   myTextbox.text =""

   frameNo = frameNo + 1

When the textbox is within a Form component, rather than being a freestanding Textbox component, I found that I could access it using the following code, where my textbox was the second item listed in the Form component’s spreadsheet, so its item number starting at zero was 1.

In the ‘Begin Routine’ tab:

myForm.items[1]['responseCtrl'].text = ""

frameNo = 0

In the ‘Each Frame’ tab:

if frameNo < 5:

   myForm.items[1]['responseCtrl'].text = ""

   frameNo = frameNo + 1
1 Like

This solution worked for me, thank you!