psychopy.org | Reference | Downloads | Github

Ratings on slider and clicking on a box to continue

URL of experiment: https://run.pavlovia.org/omidghasemi21/brighvalexp4/html/?__pilotToken=c4ca4238a0b923820dcc509a6f75849b&__oauthToken=1107c244a2dd1e37075b90faa65353b668a18dbdd815ff6ce031ef6816d9bc85

Hi,

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.

Are there any ways to solve this problem?

Thanks.