psychopy.org | Reference | Downloads | Github

Editable TextBox2 component does not register keypresses

URL of experiment: https://gitlab.pavlovia.org/Rianne/spaanstest

Offline experiment: Longitudinal_SP.psyexp (59.2 KB)

Description of the problem:
Hello PsychoPy-community,

I am currently trying to use the Textbox2 component on Pavlovia. However, the Textbox2 component does not allow me to type any text (no letter appears on the screen). Offline, I can type anything and it appears on the screen perfectly fine.

I am aware that this is a new component, so there might still be bugs in it. Hoping to use this component instead of adding code snippets because I will need participants to type sentences with accented letters and I heard it was easier using the TextBox2 component instead of writing code snippets…

Anyone knows what’s going wrong in my experiment?

Hi there,

I had to make a few tweaks but this should work: https://pavlovia.org/lpxrh6/spaanstest

I have no idea why but even though the ‘editable’ box was ticked that didn’t seem to translate to your JS code (so when I used console.log(typedText.editable) it returned false).

Manually resetting this at the start of your routine fixed this. (in your ‘typedSentence’ component you will see I have added typedText.editable = true; )

Following this though I also had to make your mouse click used to end the routine a bit more specific to allow the user to click on the textbox and type without immediately ending the routine (so you will see I added a component called ‘endButton’ and made it so that only this is clickable)

Hopefully this should work for what you need now :slight_smile:

Becca

PS. the reason I renamed your ‘text’ component was because I tried a few bug fixes before finding the solution - you can check over the commit history of my fork if you are curious.

1 Like

Oh wow @Becca, that is amazing how you figured that out!

Also, Pavlovia can now automatically (finally!) register keypresses on an azerty keyboard and also letters with accents! What a milestone!

Thank you again (I understand very little of what you actually did and what actually went wrong in generating the JS script, but happy that I asked this question. This gives hope for future studies!)

Ah I am so pleased that you are happy to have a solution :slight_smile: best of luck with your experiment!

Becca

Ah, here is the repost. I see @Becca cut me to the chase :). Thanks!

I just had one more question with regards to the output file that get’s generated after completion of the online study.

When I type a sentence (either on an azerty keyboard or a qwerty keyboard and with letters with accents), it appears on the screen perfectly fine and there are no issues there.

However, the typed sentence does not get registered as output in the .csv file (I hope I am clear enough with this). So in the variable “Typedtext.text” I can’t see what my written response was. Because I don’t know what went wrong in the first place and because of my lack of skills in JS, I don’t know what to do to fix it myself.

Any ideas?

P.s. sorry for posting this question in other threads - will keep questions within one thread in the future.

@Becca or @thomas_pronk, do any of you two know how to fix this problem? (see post above)

Hi There,

What happens if you manually add a code component, set type to JS, and in the ‘End routine’ tab type:

trials.addData(typedText._pixi.text)

Substitute ‘trials’ with the name of the current loop.

thanks,
Becca