| Reference | Downloads | Github

New mouse options - images as buttons



Hi there,

I’ve just added a new feature into the repository to make it easier for people to use visual stimuli (images, shapes, gratings, movies…) as virtual buttons. For a long time we’ve had the option to use code and insert snippets like

if sum(mouse.getPressed()) and myShape.contains(mouse):
    print("My shape was pressed")

Well what I’ve just added allows Builder to insert that sort of code for you. This is done from the Mouse Component rather than from the stimuli, but hopefully it will make sense this way. New dialog looks like below.

Mouse now has some extra options:

  • clickable: allows you to say what objects should be treated as buttons
  • store params for clicked: allows you to choose what info about the clicked object gets stored
  • new clicks only: is like “discard previous” in the keyboard
  • force end routine: used to be just True or False but this can now be “never” (like False), “any click” (like True) and “valid click” (new option so the routine doesn’t end unless the click the mouse on a “clickable” stimulus.

Use cases in my head:

  • click on the image you like most: we set both images as clickable and store the image parameter
  • visual search task: we only make the target clickable and measure reaction time until the participant clicks it
  • corsi blocks task: now really easy to measure the sequence of clicks (don’t end the trial on any click) and see if it matches the original sequence

Any thoughts? Better names that novice users will find easier to understand?


Nice. I prefer “No” or “False” rather than “Never” as the option to “End routine on press”, though.


It’s very nice, but do we have to write raw parameter name (e.g. fillColor) instead of displayed parameter name (e.g. Fill Color)? It may be difficult for beginners.


Hmm, the script definitely needs to be using the true variable name. Potentially we could perform a conversion but that would be quite tricky code to write and would need to make assumptions about what the object is going to be. I think that might have to wait for iteration two!

At the moment this is a replacement for the user having to write a Code Component (and in that Code they would need to use attributes like shape.fillColor)


Hi there,
I can’t find these features on my Psychopy. Are these features available for version 1.8?
Thank you


No. They’ll be in 1.90


Thank you for getting back to me,
I have created a preference experiment with 6 images and the participant chooses their favorite image, but the routine will finish even if they click on other parts of the screen.

Is there a way I could only allow the routine to continue if they pick the given images only?