Editable textBox not working in conditional loop

Dear all,

We are working with PsychoPy 2020.2.4 and we encounter some issues with an editable textBox. We have two editable TextBoxes in our experiment, the first one works great but the second one doesn’t show the typed responses on screen. We have no error messages. Can anyone help please? @VVV @Jbruxelm

Best Regards

Could this be due to the fact that the second textbox is in a conditional loop?

Could you share the code/psyexp files? I’ll have a look through and try to see what’s going wrong

Hi @TParsons,

Thanks a lot for helping us!

Best regards,

Demo22octobre.psyexp (87.0 KB) Word-Item.xlsx (9.8 KB)

Hello all,

Sadly, we are still stuck on this so any help is very welcome!

Best regards

I’m working with @lthieffr on this experiment and i think we have found the problem.
In the log response, we see that typing response of the second textbox (RappBisTextBox) is saved in the first textbox (RecallTextBox).
But, we don’t know how to fix this problem. Anyone can help us ?
Thank you !


Have you tried manually saving the typed responses from each box using the method here Textbox component not saving typed response


Thank you for your answer !
i’ve tried this code :
thisExp.addData (“this text”, RappBisTextBox._pixi.text) in the endroutine
but it’s doesn’t work : responses are all save but under “RecallTextBox”.
Maybe i’ve made a mistake in the code ?
Thank you again

Happy to help - have you checked your textbox parameters all correspond to those shown in the YouTube video on that thread?

Also the typed answers should be added to a new column called “this text”


Thank you for your help.
@lthieffr, @VVV and myself have tried your code in many ways but it never worked. We tried it out by adding your code in each textbox (1 & 2) but in this case psychopy stops after only one item/typed response. By adding the code only in Textbox2, the experiment works great for textbox1 but then stops after one item in textbox2, and, as always, the RappBisTextBox (textbox2) responses were saved in the RecallTextBox (textbox1)
We have seen your youtube video and our textbox composants seem to be the same than yours.
Furhtermore, we have tried to create a more simple version (without conditional loop) of our task on PsychoPy, with basically just two textboxes, one after an other and we have had the same problem :
textbox.psyexp (11.8 KB)
Sorry to bother you again but we are desperate… Could you take a look on this or at our experiment code (which is written above in replies) ? Thank you so much

Hello, I’m having exactly the same problem.
I have followed the youtube tutorial to the letter.
However, just like for @lthieffr the textbox is only editable on 1st presentation… it is not editable in any of the subsequent repetitions… the clickable element works just fine allowing me to move from screen to screen but the contents of the textbox cannot be edited… the red cursor appears & flashes as if it was ready but won’t move no matter what key is pressed…
Would very much appreciate your assistance with resolving this issue.
Many thanks!


The code needs to be added to a code component (not in the textbox fields). I can see from your experiment file that you don’t have a code component, so that is probably the issue.

The code component is found under ‘custom’ in your components panel. Add the code snippet in the thread in the ‘end routine’ tab.


The issue of the textbox not being editable after one iteration is a different issue. It is a known bug that is resolved for next release. for now you can resolve this by using an earlier version of psychopy as described here :slight_smile: Editable textbox still showing through after update

Hi Becca,
Thank you for responding so quickly. Dropping down a version i.e. to 2020.2.3 did the job.
Many thanks!

1 Like

Dear @Becca,

We have tried running the experiment using older versions of PsychoPy but we can’t manage to even start the experiment. We are getting all types of error messages, probably related to some version incompatibility issues?
We were wondering if the textbox issue (textbox being only editable on 1st presentation) would persist if we switch to Pavlovia?
Technically the “structure” of our experiment is correct, maybe if it runs in JavaScript participants will be able to type their responses for every trial?
Thank you so much for your help!
All the best,

Hi V,

So that we can help a bit more here please could you start a new thread and copy and paste the errors that you have been encountering. From there it will also be helpful to try to sync with pavlovia and share the link to your project with us so that we can see your files (sync to pavlovia >dashboard>experiment>view code>permissions (set to public) > share that URL with us)

Becca :slight_smile:

Hi Becca,
We have tried to build this experiment on PsychoPy 2020.2.5. We hae made two textboxes (textbox1 and textbox2). Each textbox is in a loop which repeat these textboxes, respectivelly, 2 and 5 times.
Our problem is : with each textbox, we can write an answers in the first occurrence but not on next iterations. Furthermore, when we looked the encode-response, we saw that : the firts occurrence of textbox1 was encoded in textbox1.text but the second occurrence in textbox1 was encoded in textbox2. And, in Textbox2, the first occurrence was encoded in textbox2.text and others (occurrence 2, 3, 4 and 5) were not encoded at all.
We have tried these codes in order to fix this problem but it’s doesn’t work :
In End Routine :
thisExp.addData(‘this text’, textbox1._pixi.text)

In End Routine of textbox1 :
def writeRoutineEndCode(self, buff):
name = self.params[‘name’]
if len(self.exp.flow._loopList):
currLoop = self.exp.flow_loopList[-1] # last (outer-most) loop
else :
currLoop = self.exp._expHandler
if self.params[“editable”]:
buff.writeIndented(thisExp.addData(“name”, name)
(currLoop.params[“name”], name, name))
(thisExp.addData(“name”, name))
In Begin Routine of Textbox 2 :
def reset(self):

Reset contents

self.text = self.startText

Make sure box is still editable (if needed)

if self.editable and self not in self.win._editableChildren: # may yet gain focus if the first editable obj

There is an other code or any solution for help us ? Or have we made a mistake in the above code ?
Sorry for bother you again. We swear we really try to make it works :sweat_smile:

Hi @Jbruxelm ,

It is clear you have been working hard to try a few solutions here so let’s try to talk through what else might/might not work! :slight_smile:

After taking some some time to look over your .psyexp files (can I please confirm that you are still working from the files shared by @lthieffr above?) There are a few things I want to highlight:

  1. Issue 1: making a single textbox component editable on each iteration of a loop. This can be fixed by using version 2020.2.3, but there were some extra edits required in your exp. a) the text field of the textbox needs a ‘placeholder’ even if just a single space b) it is good to try to not leave any fields as ‘None’ or empty (particularly if you plan to take anything online because ‘None’ is python and not JS syntax) - ‘fix’ here Demo22octobre.psyexp (87.1 KB)

  2. Issue 2: presenting multiple textbox components throughout your experiment, all of which should be editable (e.g. in your routines ‘Rapp1’, RappBis_2’ and ‘Rapfinal’). Currently, there is a known bug whereby the first textbox will be editable, but later textboxes will not (This has been logged as a bug that the developer team are aware of and have been working hard on Textbox not editable if multiple textbox components used · Issue #3267 · psychopy/psychopy · GitHub). The solutions to this are currently limited, but I will outline them here nonetheless , a) try to if possible reduce the number of routines you have such that only one textbox is needed and you are only using one textbox component b) revert to the previous method of using code components to retrieve text (a hopefully only temporarily needed fix) demos / textInput · GitLab

With regards to your self.editable solutions there @TParsons would know more quickly than me if that code solution seems correct.

As I say, I know that the dev team have been working hard on debugging aspects of the textbox component, @TParsons may have insight if I have missed any possible solutions or if it actually the bug fixes will be released soon anyway, in which case it probably isn’t worth investing time in my suggested solutions!


Hi Becca,
I follow your link (https://gitlab.pavlovia.org/demos/textinput) and i have based on it to construct textinput and it works very well :slight_smile:
Thank so much for all your help

fantastic - pleased to hear this resolved the issue. Please could you mark the corresponding answer as the ‘solution’ for future users :slight_smile: