# Alternative to .isPressedin()

**URL:** <https://discourse.psychopy.org/t/alternative-to-ispressedin/14721>\
**Category:** Online experiments\
**Created:** [July 1, 2020, 11:02am UTC](https://discourse.psychopy.org/t/alternative-to-ispressedin/14721 "2020-07-01T11:02:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ttselha](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@ttselha](https://discourse.psychopy.org/u/ttselha)\
**Post date:** [July 1, 2020, 11:02am UTC](https://discourse.psychopy.org/t/alternative-to-ispressedin/14721/1 "2020-07-01T11:02:14Z")

</div>

I have a task in which mouse clicked in a circle draws a cross and stores the location of the click. This worked well in builder using following code I modified from someone else code. There is a custom function called makeCross involved.

Begin Experiment

```auto
def makeCross(pos):
    cross = visual.ShapeStim(win, pos=pos, depth=-2, vertices='cross', size=(0.05,0.05), lineColor=[-0.8, -0.8, 1], fillColor=[-0.8, -0.8, 1])
    cross.setAutoDraw(True)
    return cross

```

Begin Routine

```auto
crosses = []

```

Each Frame

```auto
if mouse1.isPressedIn(LocCircleBig,buttons=[0]):
    crosses.append(makeCross(mouse1.getPos()))
   

```

End Routine

```auto
for across in crosses:
        across.setAutoDraw(False)

```

When I tried the task in Pavlovia online it did not work. Some discussions in discourse mentioned that .isPressedin not available in online which is disappointing. So tried following instead in the each frame section:

```auto
if (LocCircleBig.contains(mouse1) && mouse1.getPressed()[0] === 1 ){
  crosses.append(makeCross(mouse1.getPos()));
}

```

This one did not work both in builder and online. In online I got the error attached as photo.! Any help would be very appreciated. Thanks!!

[Screen Shot 2020-07-01 at 3.09.52 AM|690x415](https://discourse.psychopy.org/uploads/short-url/5xBFdVF2JxDf72D0TXrjmEy8Wym.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:** [July 1, 2020, 11:28am UTC](https://discourse.psychopy.org/t/alternative-to-ispressedin/14721/2 "2020-07-01T11:28:14Z")

</div>

> [@ttselha](#):
>
> ```auto
> def makeCross(pos):
> cross = visual.ShapeStim(win, pos=pos, depth=-2, vertices='cross', size=(0.05,0.05), lineColor=[-0.8, -0.8, 1], fillColor=[-0.8, -0.8, 1])
> cross.setAutoDraw(True)
> return cross
> 
> ```

Try

```auto
makeCross = function(pos):
    cross = visual.ShapeStim(win, pos=pos, depth=-2, vertices='cross', size=(0.05,0.05), lineColor=[-0.8, -0.8, 1], fillColor=[-0.8, -0.8, 1])
    cross.setAutoDraw(True)
    return cross

```

This might not be correct for Python code because my crib sheet contains functions in JS but not Python but hopefully you can see the principle

---

<div class="post-metadata">

**Author:** ![ttselha](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@ttselha](https://discourse.psychopy.org/u/ttselha)\
**Post date:** [July 1, 2020, 11:50am UTC](https://discourse.psychopy.org/t/alternative-to-ispressedin/14721/3 "2020-07-01T11:50:41Z")

</div>

Did you mean put these code in python part of the code when in Auto\>JS ?

```auto
makeCross = function(pos): 

```

Coz in python functions are always written in def somefunction(): of if it was meant to be js than makeCross = function(pos) { do something return something }

can you clarify please.  
Thanks.

---

<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:** [July 1, 2020, 12:06pm UTC](https://discourse.psychopy.org/t/alternative-to-ispressedin/14721/4 "2020-07-01T12:06:11Z")

</div>

> [@ttselha](#):
>
> makeCross = function(pos) { do something return something }

This one.
