# Mouse Response: Experiment exits on click

**URL:** <https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908>\
**Category:** Builder\
**Tags:** mouse, slider\
**Created:** [February 11, 2020, 11:05am UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908 "2020-02-11T11:05:28Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mariee](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@mariee](https://discourse.psychopy.org/u/mariee)\
**Post date:** [February 11, 2020, 11:05am UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/1 "2020-02-11T11:05:28Z")

</div>

I’m trying to build an experiment with a mouse response. There are two text fields that are automatically generated from the excel list. People hear a sound and have to click on one of the words.

So far that works, but once I test the experiment and click on one of the words, it exits. I’ve tried pretty much all the settings there are for the mouse response, without success.

This is the error message that I get:

```auto
    if obj.contains(mouse):
AttributeError: 'str' object has no attribute 'contains'

```

How can I get this to work?

---

<div class="post-metadata">

**Author:** ![dvbridges](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/dvbridges/32/1918_2.png) [@dvbridges](https://discourse.psychopy.org/u/dvbridges)\
**Post date:** [February 11, 2020, 12:27pm UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/2 "2020-02-11T12:27:45Z")

</div>

I think this may be that you have entered some clickable stimuli into the mouse component, and one or more of those clickable stimuli are a string, rather than a clickable object.

---

<div class="post-metadata">

**Author:** ![mariee](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@mariee](https://discourse.psychopy.org/u/mariee)\
**Post date:** [February 11, 2020, 12:30pm UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/3 "2020-02-11T12:30:11Z")

</div>

I don’t really understand what that means. How do I turns my strings into clickable objects?

---

<div class="post-metadata">

**Author:** ![dvbridges](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/dvbridges/32/1918_2.png) [@dvbridges](https://discourse.psychopy.org/u/dvbridges)\
**Post date:** [February 11, 2020, 2:26pm UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/4 "2020-02-11T14:26:17Z")

</div>

If you can tell me what you have entered as a clickable object in the mouse properties, we can see what is happening.

---

<div class="post-metadata">

**Author:** ![mariee](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@mariee](https://discourse.psychopy.org/u/mariee)\
**Post date:** [February 12, 2020, 9:39am UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/5 "2020-02-12T09:39:53Z")

</div>

Here’s what it looks like now:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/4/8/48249b5c1f57eba1dd3b5b316f75fa7b1240dc0a.png)  
option1 and option2 are also the names of the columns in the .csv from which the options are loaded. Does that help or do you need more information?

---

<div class="post-metadata">

**Author:** ![dvbridges](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/dvbridges/32/1918_2.png) [@dvbridges](https://discourse.psychopy.org/u/dvbridges)\
**Post date:** [February 12, 2020, 1:22pm UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/6 "2020-02-12T13:22:02Z")

</div>

Yes, thanks. `option1` and `option2` are strings, imported from your conditions file. You can change this to the actual text components `option_1` and `option_2` (text components are objects) and you should be able to click the text on screen .

---

<div class="post-metadata">

**Author:** ![mariee](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@mariee](https://discourse.psychopy.org/u/mariee)\
**Post date:** [February 12, 2020, 2:59pm UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/7 "2020-02-12T14:59:51Z")

</div>

I tried that, but now I get this error:

```auto
    mouse.clicked_option_1.append(obj.option_1)
AttributeError: 'TextStim' object has no attribute 'option_1'

```

☹

---

<div class="post-metadata">

**Author:** ![dvbridges](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/dvbridges/32/1918_2.png) [@dvbridges](https://discourse.psychopy.org/u/dvbridges)\
**Post date:** [February 12, 2020, 3:05pm UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/8 "2020-02-12T15:05:42Z")

</div>

That will be related to using ‘option\_1’ in the store params field. You might instead want to store its name, so use `name` instead in the store params field, and the name of `option_1` (or 2) will be stored.

---

<div class="post-metadata">

**Author:** ![mariee](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@mariee](https://discourse.psychopy.org/u/mariee)\
**Post date:** [February 12, 2020, 3:12pm UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/9 "2020-02-12T15:12:03Z")

</div>

Thanks! It seems to be working now! 🙂

---

<div class="post-metadata">

**Author:** ![taliwe](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@taliwe](https://discourse.psychopy.org/u/taliwe)\
**Post date:** [April 5, 2021, 7:56am UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/10 "2021-04-05T07:56:34Z")

</div>

I get a similar error:

if obj.contains(resp\_mouse):  
AttributeError: ‘list’ object has no attribute ‘contains’

[conditions.xlsx](https://discourse.psychopy.org/uploads/short-url/5rBl4U3EhrZpzRAHdheOLI5iuAU.xlsx) (8.4 KB)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/0/8/08fb3ad33f215b71e121897df36f8cf54ab8e602.png)

---

<div class="post-metadata">

**Author:** ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)\
**Post date:** [April 5, 2021, 7:58am UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/11 "2021-04-05T07:58:41Z")

</div>

Could you insert `target_x` without the quotation marks?

What version of Psychopy are you using? I think that was a [bug](https://github.com/psychopy/psychopy/issues/3651) with an earlier version of Psychopy. It might help to update to a newer version.

---

<div class="post-metadata">

**Author:** ![taliwe](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@taliwe](https://discourse.psychopy.org/u/taliwe)\
**Post date:** [April 5, 2021, 3:44pm UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/12 "2021-04-05T15:44:07Z")

</div>

Psychopy3 v2021.1.2

---

<div class="post-metadata">

**Author:** ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)\
**Post date:** [April 5, 2021, 6:31pm UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/13 "2021-04-05T18:31:43Z")

</div>

Your issue should be fixed in v2021.1.3 if you remove the quotation marks. 👍

---

<div class="post-metadata">

**Author:** ![taliwe](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@taliwe](https://discourse.psychopy.org/u/taliwe)\
**Post date:** [April 6, 2021, 6:49am UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/14 "2021-04-06T06:49:06Z")

</div>

Unfortunately, It did not help…

```
if obj.contains(resp_mouse):

```

AttributeError: ‘list’ object has no attribute ‘contains’

![target_x](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/c/4/c4830a38c04c399f90e24bb5205ed254a96df3fb.png)

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [April 6, 2021, 6:54am UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/15 "2021-04-06T06:54:23Z")

</div>

> [@taliwe](#):
>
> `if obj.contains(resp_mouse):`

Which object are you referring to? Perhaps you mean  
if target\_x.contains(resp\_mouse):

---

<div class="post-metadata">

**Author:** ![taliwe](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@taliwe](https://discourse.psychopy.org/u/taliwe)\
**Post date:** [April 6, 2021, 7:41am UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/16 "2021-04-06T07:41:19Z")

</div>

Thank you for your help!  
I tried to follow Tutorial 1: How to make a Posner in PsychoPy (2020); start at 10:00

[![](https://img.youtube.com/vi/fIw1e1GqroQ/hqdefault.jpg "Tutorial 1: How to make a Posner in PsychoPy (2020)") ](https://www.youtube.com/watch?v=fIw1e1GqroQ&t=1s)

I had a mistake, now I fixed it: in Clickable stimuli= target (not target\_x from excel), however I get the same error…

> if obj.contains(resp):  
> AttributeError: ‘list’ object has no attribute ‘contains’

 ![fig2](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/b/7/b750c85d45bbd28609206c0cd81e38b397feb0ff.png) ![fig1](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/d/5/d5b0ab1b585d6e94c968f1f17de39c3fee3c6487.png)

I also tried to create a polygon…

> [@Question on implementing clickable stimuli](https://discourse.psychopy.org/t/question-on-implementing-clickable-stimuli/6874):
>
> Hi, I’m a beginner trying to construct an experiment in Builder, but has quickly run into problems. The gist of it is that the participant will be presented with an image. The image contains several discrete components (geometrical figures), and the point of the task is to click on the correct component (which one/s that are correct depends on some prior information). I know what I’d like to do – define certain areas of an image as clickable. Then, if possible, define some clicks as correct a…

However, I can not put “target\_x” (title in excel) in pos (of cycle)  
NameError: name ‘target\_x’ is not defined

 ![fig5](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/e/9/e94614ca2a49ead906f9cc563e0436e587bc9d21.png) ![fig4](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/1/a/1acee2bf2dc1a4b6f5c420431c6939959d45f090.png) ![figure3|690x320]

---

<div class="post-metadata">

**Author:** ![Aamina\_k](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@Aamina\_k](https://discourse.psychopy.org/u/Aamina_k)\
**Post date:** [April 16, 2021, 10:23pm UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/17 "2021-04-16T22:23:23Z")

</div>

Hello, I was wondering if you knew why this error happened?  
I am getting the same error:

if obj.contains(mouse):  
AttributeError: ‘list’ object has no attribute ‘contains’

I am making the corsi task in psychopy. It is working by itself, however when i add it to a group of 3 other tasks only the corsi seems not to work and i get that error. I have copied what i did exactly but cant seem to figure out why it ‘clashes’ with other tests…

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [April 17, 2021, 6:48am UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/18 "2021-04-17T06:48:31Z")

</div>

Add a comma after the clickable stimulus in the mouse component.

---

<div class="post-metadata">

**Author:** ![Aamina\_k](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@Aamina\_k](https://discourse.psychopy.org/u/Aamina_k)\
**Post date:** [April 17, 2021, 2:36pm UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/19 "2021-04-17T14:36:37Z")

</div>

Hello! I have commas after the clickable stimuli but i still get the same error unfortunately. I put a comma after the last clickable stimuli to see if that worked but that did not work either. I also tried adding a comma after ‘name’ and that did not work either

I have attached a screenshot to show this:

 ![Screen Shot 2021-04-17 at 15.33.55](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/6/c/6cfc51a2948358c58e59e0fd808410cd8854d3b6.png)

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [April 17, 2021, 2:42pm UTC](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908/20 "2021-04-17T14:42:38Z")

</div>

Try removing the quotes. You are referring to components not text

[Next page](https://discourse.psychopy.org/t/mouse-response-experiment-exits-on-click/10908.md?page=2)
