Editable TextBox2 component does not register keypresses

URL of experiment: Rianne / Spaanstest · GitLab

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.

2 Likes

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

Your suggestion turned out to work, @Becca!

We just tried it yesterday!

woo! happy to hear!

Becca

Hello!

I am having a similar issue where I would like to run some code on the text that a participant types using the editable textbox. However, it isn’t registering any of the text. I tried using the getDisplayedText() function and I got an error saying that ‘TextBox2’ object has no attribute ‘getDisplayedText’. What command can I use to refer to the text that the participant wrote in the editable textbox?

I also am writing the majority of my code in python, so I will need a way to set a variable that refers to the text in python code.

@hcheckeye this isn’t really the same subject as the thread but finding the text in python should be as simple as calling yourTextboxComponentName.text ; also check your output files for the names of logged variables you can use, or check the documentation.

In case you aren’t aware, if you are hoping to move online, you will have to make sure all your Python code translates well into Javascript; you can use Wakefield Carter’s crib sheet for help with this.

@Becca where exactly do you add typedText.editable = true; ?

I am having the same problem in v2021.1.2; and tried adding myTextbox2Component.editable = true; at the “begin routine” portion of a code component on the JS side; but still can’t type words online.