# Mouse not saving correctly?

**URL:** <https://discourse.psychopy.org/t/mouse-not-saving-correctly/14864>\
**Category:** Builder\
**Tags:** mouse\
**Created:** [July 7, 2020, 9:59am UTC](https://discourse.psychopy.org/t/mouse-not-saving-correctly/14864 "2020-07-07T09:59:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lpxhs5](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@lpxhs5](https://discourse.psychopy.org/u/lpxhs5)\
**Post date:** [July 7, 2020, 9:59am UTC](https://discourse.psychopy.org/t/mouse-not-saving-correctly/14864/1 "2020-07-07T09:59:25Z")

</div>

URL of experiment: [Pavlovia](https://pavlovia.org/lpxhs/iblettertask)  
(not fully converted into JavaScript yet)

My experiment involves letter stimuli flashing onscreen with one letter every 150ms. Participants need to click the screen once per trial whenever they choose. They’re later asked which letter was onscreen when they clicked the screen.

I’m struggling to correctly save the letter that was genuinely onscreen when the participant clicked.

Here’s my mouse component:

 ![Screenshot 2020-07-07 at 10.29.57](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/7/2/728dd3ee510f501158a8dab960f5d753a5edccd8.png)

All the ‘clickable stimuli’ are separate image components (named: P, X, D, etc) in the same routine as the mouse component.

When I have it set to save mouse state ‘on click’, I get this in the output file:

 ![Screenshot 2020-07-07 at 10.29.47](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/e/c/ec9c80907bd59e0b8aa4ae4ff98dee74acd412b3.png)

A list of all the clickable stimuli.

When I set the mouse component to save mouse state ‘final’, no name is saved, the mouse.clicked\_name the column is missing.

I tried putting this code into the each frame tab:

```auto
if mouse.getPressed()[0]==1:
    clicked = mouse.clicked_name

```

And this in the end routine tab:

```auto
trials.addData('trialMouse', clicked)

```

This didn’t work, I still got a long list containing the names of all of the clickable stimuli.

I then tried just putting just this in the end routine tab:

```auto
trials.addData('trialMouse', mouse.clicked_name)

```

But that produced the same result.

I have a feeling that the clicked\_name is saving, but it’s being overridden on each frame.

For clarity, these are all my current tabs on my code component:

 ![Screenshot 2020-07-07 at 10.54.11](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/a/f/af1aec2558756dd3b5fb60bd67a06f07c017ce4e.jpeg) ![Screenshot 2020-07-07 at 10.54.14](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/0/6/06bfa3d663c2b708fa8c89dabe1ab03d193badc3.jpeg)

 ![Screenshot 2020-07-07 at 10.54.20](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/b/a/bae8a0a015c9bd8ec95a8438a27a098184b14049.png) ![Screenshot 2020-07-07 at 10.54.23](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/a/9/a942ff96fa4cd3b92b90c2f806fafa864d879440.jpeg)

How do I make this so that it saves only the stimuli onscreen when the participant makes a left mouse click?

Thank you!

---

<div class="post-metadata">

**Author:** ![lpxhs5](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@lpxhs5](https://discourse.psychopy.org/u/lpxhs5)\
**Post date:** [July 7, 2020, 2:57pm UTC](https://discourse.psychopy.org/t/mouse-not-saving-correctly/14864/2 "2020-07-07T14:57:23Z")

</div>

I’ve made it so that the mouse component ends after a click has been made:

 ![Screenshot 2020-07-07 at 15.52.53](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/b/0/b05ab65eec14537aad8ed6018d8f771d20000f9a.png)

I did this so that the mouse can’t possibly record any extra stimuli names after the first click has happened.

Doing this now returns an empty list .

I’m now wondering if the stimuli duration is too short for the name to properly be saved? Each letter stimulus is onscreen for 150ms. Perhaps the mouse just doesn’t get a chance to save the name of the clicked stimulus?

However, this doesn’t explain why the experiment was outputting a list with all the possible clickable stimuli names before…

I’m really lost here, any help would be greatly valued - thank you! 🙂

---

<div class="post-metadata">

**Author:** ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)\
**Post date:** [July 14, 2020, 9:20am UTC](https://discourse.psychopy.org/t/mouse-not-saving-correctly/14864/3 "2020-07-14T09:20:50Z")

</div>

I think this is the same as a bug which was reported on GitHub:

> <https://github.com/psychopy/psychopy/issues/2844>
>
> If you set "end routine on press" of a mouse component to "never", its status is never updated and you cannot...

I’ve fixed it in the Master branch on GitHub, so the fix will be in the next release. For the time being, is it possible to set “End Routine On Press” to a different value, or would that break your experiment?
