psychopy.org | Reference | Downloads | Github

Editable textbox only accepts input on first trial

OS Mac High Sierra
PsychoPy version 2021.2.1 (and now 2021.2.2)
Standard Standalone? (y/n) y
What are you trying to achieve?:

I want participants to estimate the age of someone in a photo by typing a number into an editable textbox (32 trials), and I’d like for the experiment to run online

What did you try to make it work?:

I made an editable textbox component in builder! It is called AgeEst below.

What specifically went wrong when you tried that?:

The experiment runs fine on my computer, but when I pushed it to Pavlovia, I can estimate the age of the first photo, but none of the subsequent photos. The mouse click successfully ends each trial.

On the first trial, I can enter the age, as shown below.

When I click the mouse, the next trial shows up, but no cursor. I can click through all my stimuli, but cannot enter any more ages.

I have looked at this post Editable textBox not working in conditional loop and others for guidance, but it doesn’t seem to be quite the same situation.

Also added the code referenced in Editable TextBox component does not register keypresses after updating to version 2021.1.2 AND textbox.editable = true from Editable TextBox component does not register keypresses after updating to version 2021.1.2 nothing changes.

And truly baffling, when I press escape when testing online, the cursor comes back, and I can type stuff in for one trial. When I click the mouse, all subsequent trials have no cursor, just a mouse click that ends the trial.

Any thoughts?

1 Like

Hi There,

This does indeed look like a bug - sorry you encountered it but thanks for reporting it. This has now been flagged to the developers here: Textbox: only editable on first iteration of loop · Issue #454 · psychopy/psychojs · GitHub

Let me look into if there is a temporary solution whilst they work on a fix there!
Becca

Hi there,

OK the temporary fix is, add a code component. In the “Begin Routine” tab write:

textbox.refresh()

where “textbox” refers to the name of your textbox component (for you it will be AgeEst.refresh())
Hope this helps!
Becca

1 Like

Thank you so much, Becca! That does the trick.
It’s interesting, the first trial still seems to be a little different, but not in a problematic way for my purposes. If I put a placeholder (space or word) in the textbox as a default, the placeholder doesn’t show up until the second trial, and then it stays for all subsequent trials. (I just deleted the placeholder space, and everything looks just right.)
Thanks again for your help!
Best,
Molly

Interesting observation - we can check that out, thanks for reporting it (i’ve linked this post in the github report) - textbox is still relatively new online so we’re still debugging it! Thanks for helping us do it!

Becca

I’m encountering what seems like the same issue, but the textbox.refresh() solution doesn’t seem to work for me.

The issue seems identical: my editable textbox accepts input only on the first trial. On subsequent trials I can’t type anything, unless I press escape, or F11 to toggle fullscreen, or F12 to bring up the console (I’m working in Chrome, by the way). All those actions bring the cursor back and allow me to type again, but only for that trial. On the next trial, the cursor is gone again and I have to bring it back again the same way.

As suggested, I added a textbox.refresh(); line in JS in the “begin routine” tab. This doesn’t solve the problem for me. I also tried changing the place where this code component appears in the Builder order, which changes where the .refresh() line appears in the compiled JS code (either before textbox.setText() or after), but that makes no difference. I then tried adding the textbox.refresh() command to be executed every frame, but again no luck.

Am I doing something wrong? The .refresh() command should be in JS, correct? (In any case, if I put it in Python and have it auto-translated, it comes out the same.)

1 Like

Hi There,

Yes that sounds like you are implementing it correctly! Here is a demo of my fix so that you can cross check. textbox_bf_2021.2.2.psyexp (11.9 KB)

Some things to check:

  1. Is your code component below your textbox component in your routine.
  2. does the .refresh refer to the name of the current textbox component (e.g. in this demo that is myTextbox.refresh().

Hope this helps,
Becca

Thanks for your response, Becca. I’ve now moved on to using the “old” text input method (e.g. demos / textInput · GitLab) which works well for me (better actually), so I probably won’t continue trying to debug the editable-textbox approach, but in case it helps others, or helps you address this issue in the future:

  1. I tried it with the code component in a number of different places in the routine (including before and after the textbox) and it never worked
  2. Yes, my textbox was called rsp_textbox and so my refresh command was rsp_textbox.refresh()

Hi There,

OK I am pleased you fixed your issue. So that we can continue to debug the issue our side please could you share the version of your experiment where the bug was?

Thanks,
Becca

Sure. This is my code: Ruben van Bergen / OcclusionTask · GitLab

If you fork that, I guess you should be able to revert to one of the versions that had the bug (right? correct me if I’m wrong). E.g. the version called “Fixed bracketed for-loop” has the bug, and after that I started to try to fix the problem. In version “Debugging textbox issue #6” I first implemented the .refresh() fix, and then later versions are variations on that fix.

Let me know if you need anything else.

Edit: should have clarified: the actual experiment is in the builder-doodle{.psyexp, .py, .js, …} files.

Thank-you!

Hi there! I am facing the exact same issue, though the solution you presented here is not working for me either. I was wondering if there is another solution?

Hello there! I appeared to have the same issue and the above solution did not work for me either. When I added the code and tried to run the experiment locally, I was told that “AttributeError: ‘TextBox2’ object has no attribute ‘refresh’.” I wonder if there is any update on this question or any thoughts on the issue I encountered?

Thank you!

Hi
I had the same problem with a textbox (in Pavlovia) not being clickable unless F11 was pressed between trials within a loop.

Adding mytextbox.refresh() in begin routine and mytextbox.reset() at the end of a routine has fixed the issue.

https://gitlab.pavlovia.org/StewartKeating/textbox

Hope that can help someone.
Thanks
Stew

1 Like