URL of experiment:
URL for the code: Mihai Toma / sns_circles · GitLab
Description of the problem:
Error message: online, when I reach the routine that has 2 buttons defined, they don’t show up on the screen, and when I click anywhere, I receive the error message:
Reference error: buttonYES not defined.
The experiment is a save as of a previous experiment. Everything is working well locally using Python. These experiments were built using PsychoPy v2021.1.3. The base experiment was working flawlessly both offline and online.
In the previous experiment, this error did not occur at all.
Only change I did was:
Install PsychoPy v2023.1.3 to see if other things for a different experiment have changed. I observed that no other things have changed.
Uninstall PsychoPy v2023.1.3 and re-install v2021.1.3. Save As the experiment again and re-sync it online.
I get this error after these changes in versions.
Now I have V2021.1.3 and have uninstalled the previous one. I have un-installed it before reinstalling v2021.1.3
Any suggestions on how to tackle this?
I checked the code in between both experiments and nothing is different for the buttons sections at least, so it should not appear.
This is rather urgent.
This is the error message:
Looking at your JS code, it doesn’t look like the buttons are being declared.
When I need to work online with buttons, I use a polygon and text over it. As much as I know, buttons are not yet supported online:
Buttons don’t work online yet. I got that error when updating the Wisconsin Card Sorting test, so I resorted to an image.
I am unsure if it was updated, but it might be the issue.
Thank you, Chen and wakcarter.
The thing is that before the (un)installation of PsychoPy v2023.1.3 vs. v2021.1.3 , the experiment did work online…including the buttons.
Now they don’t work.
I’ll try the solution proposed by Chen with the polygon and text over it.
I quoted a message from @wakecarter from April 2022.
It’s possible buttons now work online, I didn’t test it myself, and I didn’t find any newer information about it.
But the thing that is wrong with your experiment is the fact that your buttons are not being declared at all in the JS file.
But I have defined them as such in a code section BEFORE they are actually usable:
I compile and synchronize with the online Pavlovia files and still I get the same error.
Did you try placing this code component in the routine hierarchy after your buttons?
It’s difficult to understand the whole picture, the project you have sent is 600MB+ and has multiple experiments.
If you want to make it possible to help, please separate it into a single, simple project.
I also tried placing them after the buttons ,but that still doesnt work. But given that they’re declared after the point when they’re being used… it would make sense.
The file is
And I see they’re declared here at lines 1449 and 1450.
I’m currently testing with images and polygons and I don’t understand why they cannot find this resource:
The file is there, I checked even the online resources and i have even added the files manually.
How did you set the image?
Can you take a screenshot of the online resources and the image component?
This is how I set the image in the builder:
And this is where the image is located:
It looks to be declared just fine.
Do you have a separate version of the study on Pavlovia? One that doesn’t have multiple experiments on it?
That way, it will be easy to take a look myself.
I compiled it in a separate online version:
Now I have the following error:
But I think I have it because I declared the “win” before referencing the buttons:
In the above routine, the images and polygons are not active, they are disabled, only the buttons are active (and all other elements that require the buttons).
Use / not \ in your file locations
I think my crib sheet has something on how to hide the mouse cursor online
I am currently trying to see if I can make it to work again with the buttons, not the images.
Any idea of why the buttons don’t work anymore?
I just posted the final (curated) version in my previous message
I am looking here:
But I wrote that section of the code because the mouse cursor was not appearing on the window where users need to click on either of the two buttons.
Therefore, I don’t want to hide the cursor, but show it.
Without that line of code, the mouse cursor is not visible.
As the cribsheet states, you can choose when to show/hide it.
Hide the mouse cursor
You need to add the following code when you want to un-hide it:
Other than that, everything seems to be working now.
Thanks, Chen and wakecarter.
I solved the problems, but now I ran into another issue related to buttons again.
At the end of this experiment, I want to re-direct users to a google form via a button.
This is the routine:
However, at the end, I cannot see this button, but also I don’t get the error I had before:
“button is not defined”
I just get an empty window without the actual button. The button should be right below the writing (Where I drew the red shape):
Do you have a workaround for this?
Thanks again for the help
Change your backward slashes to forward slashes.
Best wishes Jens
If you want to show the mouse, try adding a tick in Experiment Settings / Properties / Show mouse