psychopy.org | Reference | Downloads | Github

Box can't be clicked in Pavlovia

Description of the problem:
I am trying to conduct an experiment about making predictions about facts, where participants get the option to indicate when they think the ‘fact’ is not true. To do this, I have written Python code to display a white box that turns black when clicked. However, when auto converting this to JavaScript in order to run the experiment online, the white box does not turn black anymore. Here is the JavaScript code:

Begin routine, I expect that this works:

Checkboxes = [Implausible];
Clicked = [];
for (var box, _pj_c = 0, _pj_a = Checkboxes, _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
    box = _pj_a[_pj_c];
    box.color = "white";
}

Each frame:

var _pj;
function _pj_snippets(container) {
    function in_es6(left, right) {
        if (((right instanceof Array) || ((typeof right) === "string"))) {
            return (right.indexOf(left) > (- 1));
        } else {
            if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
                return right.has(left);
            } else {
                return (left in right);
            }
        }
    }
    container["in_es6"] = in_es6;
    return container;
}
_pj = {};
_pj_snippets(_pj);
for (var box, _pj_c = 0, _pj_a = Checkboxes, _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
    box = _pj_a[_pj_c];
    if ((mouse.isPressedIn(box) && (! _pj.in_es6(box.name, Clicked)))) {
        box.color = "black";
        Clicked.push(box.name);
    }
}

Does anyone have a clue what could be going wrong here? I haven’t worked with JavaScript before and I can’t find out what’s going wrong. Thanks so much in advance!

Please could you show me what the Python code looks like? I find it easier to read and you’ve said you are using auto translation.

Yes, of course, thank you for your reply! Here is the python code:

Begin routine

Checkboxes = [Implausible]
Clicked = []
for box in Checkboxes:
    box.color = "white"

Each frame

for box in Checkboxes:
    if mouse.isPressedIn(box) and box.name not in Clicked:
        box.color = "black"
        Clicked.append(box.name)

This seems to work without a problem on my laptop.