To get a working Mouse Contingent Display, you will need three main components:

  • iFrame code component
  • Your stimuli
  • HTML code

To set up the iFrame code component, see https://people.beocat.ksu.edu/~karipayne/psychopy/introduction-to-custom-code/03-adding_an_iframe/

In the same routine you place this code component, you will also add your visual stimuli, like images or videos. If you want a mouse contingent overlay on multiple routines, you will need to add a code component to each one. However, you will not need to repeat the code in the “Begin Experiment” tab.

You can make individual changes to what data is collected in each mouse contingent display iteration. For this, see https://people.beocat.ksu.edu/~karipayne/psychopy/mouse-contingent-display-overlay/03-Customizing_HTML_code/

Some important iFrame quirks to note:

  • When an iFrame is open, the mouse is considered to be on the iFrame, and not on the underlying stimulus window. If you want to implement clickable stimuli, you will need to do so in the JS portion of the HTML file.
  • This also means that your mouse information will not be measured by any PsychoPy Mouse Objects you enter into your routine. You can customize the collected information within the HTML code.
  • By default, the iFrame will close when the routine it is in ends. This means you can set the routine to end after a video is finished, or after you have shown a set number of images within a routine, and not have to worry about the iFrame sticking around.
  • You can ONLY pilot the experiment with the iFrame after it is uploaded to Pavlovia.

After you add in your stimuli, you will need to add in the HTML code for the mouse contingent display. For this, see the next section.