Remove text from textbox

Hello everyone,

In my experiment, I am using the textbox option throughout my experiment. At the beginning of the experiment, I ask questions, and in the textbox, it has the text “type here” so participants know where to type.

I was wondering if there is any way that Psychopy can remove the text after participants saw it just so when they type in their responses, the data come out cleaner. I don’t want to see the “type here” text on the excel file for every participant.

Thank you

Hi @Serena, for clarification: Is this the same routine containing this textbox that gets reused / looped during the experiment, or are you talking about different routines with different textboxes?

You could use a :code: Code component with the following in its “Each Frame” tab to make it so that a textbox with only the start text in it clears its contents when it receives focus (aka when the caret starts flashing and it starts receiving text input):

if textbox.hasFocus and textbox.text == "Type here...":
    textbox.text = ""

Then just set the text value of that textbox to be Set Every Repeat and be Type here... so that it resets to the start text each repeat.

The issue with this would be that there always has to be one object which has focus, so if you only have one editable textbox on screen then it will have focus from frame 0 and so the start text won’t be visible. But if you wanted to implement a grace period of 1s you could set the textbox to be non-editable and do:

textbox.editable =  t > 1
if textbox.hasFocus and textbox.text == "Type here...":
    textbox.text = ""