| Reference | Downloads | Github

Access mouseclick.clicked_text works in python but not js

Hi! In an experiment we have multiple “clickable” numbers (and a plus and minus sign) on screen and the ones having been clicked should appear at the bottom of the screen, visualising the calculation. In PsychoPy it works perfectly fine to use a code snippet (each frame) and to access choose_nrs.clicked_text [where choose_nrs is the mouseclick-variable] joining them via

calculation = " ".join(choose_nrs.clicked_text)

The variable ‘calculation’ is then visualised via a text stimulus, updating each frame. I try to do the js-pendant via

calculation = choose_nrs.clicked_text.join(" ");

inside the code snippet (on the js-side). However, nothing seems to be written into the variable/array choose_nrs.clicked_text so that nothing can be joined and consequently, nothing is displayed.

Do you know why this is?

All the best and stay healthy

In other words: What I need is the option to display text that I just clicked. It works when I start the experiment from the Builder, it does not work when I start it from (as a pilot experiment). JavaScript does not seem to be able to gather that information from the xxxxx.clicked_text variable.

@bassible, I believe this is an issue raised on GitHub, see below. For online tasks, text is not working as a clickable object. So, when you click the text, the clicked_text array will remain empty. An alternative is to use transparent shapes as a background for each one of your pieces of text, and link those shape names to the actual text. e.g.,., if polygon_1 is clicked, save text from text_1 text component.

1 Like

Thanks so much for the quick and helpful reply!!
It’s a bit more code snippetting but worth it in this case (bc it works)