My experiment presents some statement and after 5 seconds in each trial, a slider, a mouse and a box appear. I want to make sure that participants rate their response on the slider and then click on the box to continue to the next trial. So, I used this code in the each frame tab and it worked fine:
// continue if both slider and mouse is clicked
if (mouse_save_prac.getPressed()[0] === 1) {
clickable = [save_box_prac];
for (const obj of clickable) {
if (obj.contains(mouse_save_prac)) {
if (obj === save_box_prac && practice_bright_slider.getRating()) {
continueRoutine = false;
} else {
continueRoutine = true;
}
}
}
}
However, the problem is that if participants click on the screen before the mouse onset, they will got this error: TypeError: Cannot read property ‘map’ of undefined.
Before I had a mixture of builder and code visual components but I’ve now replaced all of the builder visuals with code, because only the builder components were being displayed. I had to add a keyboard component so that the routine got processed at all.
The experiment is designed for a touchscreen, and therefore looks at the mouse location rather than clicks. However, I’ve added a gap before it starts to ensure that the screen is not being actively touched when the trial routine starts.
Edit: On my phone I’m getting TypeError: undefined is not an object (evaluating ‘color.rgb.map’) which suggests that it’s not related to the mouse at all.