| Reference | Downloads | Github

TypeError: state.toLowerCase is not a function

URL of experiment:

Getting this error when running my experiment online. I think it’s related to the textbox component. I’m wondering whether the issue has been resolved on PsychoPy’s end and if not what can be the workaround for this ?

I’m still using code for editable text but there might be some information in these threads.

I guess I’ll just have to wait for the new release then. Before that, code seems to be the only way. The TextInput experiment I tried, the backspace and space key only work once, and after that ‘backspace’ and ‘space’ would come up and there’s no way to change, did you have a solution for that?

Feel free to post your code so I can take a look

Anyone know when the new version will be released? I can’t recruit until January anyway…so I’ll prob wait.

Just in case the wait is too long, @wakecarter can you share your code solution to getting the input textbox to work on Pavlovia? Is it a code-insert workaround? Thanks!

Hi @tokaalmighty, I don’t see any state variables in your code, has the script maybe changed since first posting this question? Thanks, s.

The linked experiment was only changed on the line that the error pointed to, AutoDraw, I changed it from true to false. Even though the error disappeared, the textbox is now unresponsive.

I have decided to use code for editable text and thus removed the textbox component as it was faulty in some way…and have since initiated a new repo for this new version.
Thanks for looking into my issue!

Here’s the Python code from one of my experiments.

Begin Routine

modify = False

Each Frame

if cursorCounter >= 30:
    if cursorVariable=='_':
        cursorVariable=' '

keys = event.getKeys()
if len(keys):
#Start the clock on first key
    if textStarted == 0:
        textStarted = 1
    if 'return' in keys and len(displayText)>1:
    elif 'space' in keys:
        displayText+=' '
    elif 'period' in keys:
    elif 'comma' in keys:
    elif 'apostrophe' in keys:
    elif 'minus' in keys:
    elif 'backspace' in keys:
    elif 'lshift' in keys or 'rshift' in keys:
        modify = True
    elif len(keys[0])>1:
    elif modify==False:
        displayText += keys[0]

End Routine

thisExp.addData("typedWords", displayText)
thisExp.addData("thinkingTime", rt0)
thisExp.addData("typingTime", rt1)
text_feedback.text='Thinking time = '+str(round(rt0,2))+'s\nTyping time = '+str(round(rt1,2))+'s\n'+displayText

1 Like

Hi @wakecarter, I have similar code and my editable text works good locally, but when running online, the screen always preserves the last key press, in other words, it’s not empty where participants are supposed to type into. Did you experience the same issue?

I think I have in the past, which is why I have event.clearEvents() in the Begin Routine tab.

Is JavaScript the same?

Yes, but you need event=psychoJS.eventManager;
in code_JS

I had that included in the first routine of my experiment code component, but getting the error

TypeError: event.clearEvent is not a function

Events is plural

1 Like

Oops, thanks, it’s working properly now!

I have similar problem but I’ve accidently realized something:

I’ve created a new experiment in order to understand the textbox component. If I add the “Array.prototype.append = [].push;” code at my experiment. I get “TypeError: state.toLowerCase is not a function” if I remove it, experiment works perfectly.

I’ve have also demonstrated it with below video:

What I need is to use both features (textbox and Array.prototype.append = [].push). Can anyone help about this issue?

Thanks for sharing this! I tested it out and I am getting:

Reference Error: not defined

Do I need to define it in Before Experiment or Begin Experiment?

As per my crib sheet I have myClock = core.Clock() on the Python side and myClock = new util.Clock(); on the JS side in Begin Experiment in a Both code component in the start routine.

Thanks - when I add that and test it locally I get this error:

thisExp.addData(“typingTime”, rt1)
NameError: name ‘rt1’ is not defined

I get the same error on Pavlovia, that myClock is not defined…