OS (e.g. Win10): Mac High Sierra 10.13.6 PsychoPy version (e.g. 1.84.x): 2020.2.10 What are you trying to achieve?: Is there a way to clear the textbox between responses?
We are using the naming animals task, in which participants will free recall animal names for fifteen minutes. We would like to each name to disappear from participant view after entering.
dog (clear)
cat (clear)
bear(clear)
etc.
What did you try to make it work?:
Keyboard and textbox feature tinkering in builder.
I don’t have any code to show because I have not tried to fix this issue in code. I have not had my coding class yet (1st year grad student) and so I have only worked in builder thus far. I am more than happy to try coding, though, and am assuming therein lies the solution.
I know the keyboard feature doesn’t keep responses on display, but it also doesn’t show the responses at all. We do want participants to see their individual responses.
I also know that using multiple textboxes and a mouse (or keyboard) feature combination means that participants could click away to a new, blank box after each response. However, we have no idea how many responses they will give (literature suggests anywhere form 80-150), so we would have no idea how many textboxes to create, and participants will differ anyways.
So does anyone know of how to use textbox (or another feature) so that when participants press enter, the response disappears from view?
in the newest version of PsychoPy (2021.1) we added a Button component, for which you can set a “callback” - a little bit of code to run when the button is pressed. What you could do is make a Variable component (let’s call it textStore) with its value at the start of the experiment set to be [] (i.e. an empty list), then make a “submit” button whose callback is:
The code would set the contents of the TextBox to be an empty string, so whether you’re clearing its initial value or values added since depends on when the code is executed. Did you put the code in a button callback or a code component?
So after I read this comment I figured I was doing something in button wrong, so I redownladed psychopy version 2021.1, restarted my computer, and that time around everything worked perfectly, so my issue after trying your advice was probably just a little glitch.