psychopy.org | Reference | Downloads | Github

Editable Textbox no autofocus online

URL of experiment: Eva Specht / TextBox no autofocus online · GitLab

Description of the problem:

In my experiment I use the editable TexBox (Beta) component to collect answers.

Offline, the text box gets auto-focus so that the test subjects don’t have to keep manually clicking in the box before typing in the answer.

Online, however, the text box does not get auto-focus. In each trial, the box must be manually clicked with the mouse before the answer can be typed and ‘Enter’ can be pressed to move on to the next trial.

Is this a bug in PsychoJS and does anyone have a solution to this problem?

I am using Builder, PsychoPy v2020.2.10 on macOS Catalina 10.15.7.

Thanks for helping!

Hi there,

You need the following line of code in a JS code component in the each frame tab to bring the textbox to focus online:

textbox_name._pixi.focus()

Hope this helps,

Becca

Ps. We are looking to make the behaviour of the textbox online equivalent to the local textbox in this regard! :blush:

1 Like

Had the same error, this fixed it for me. Thank you, Becca!

Thanks, Becca, that solved the issue!

Happy to help! I hope you don’t mind I marked the solution here for future users :slight_smile:

All the best!

Becca