# Stimuli changes colour when clicked but 'flickering' and not responding immediately

**URL:** <https://discourse.psychopy.org/t/stimuli-changes-colour-when-clicked-but-flickering-and-not-responding-immediately/9118>\
**Category:** Builder\
**Created:** [September 20, 2019, 1:48pm UTC](https://discourse.psychopy.org/t/stimuli-changes-colour-when-clicked-but-flickering-and-not-responding-immediately/9118 "2019-09-20T13:48:53Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [September 23, 2019, 2:38pm UTC](https://discourse.psychopy.org/t/stimuli-changes-colour-when-clicked-but-flickering-and-not-responding-immediately/9118/2 "2019-09-23T14:38:13Z")

</div>

Hi @auriga, the images are flickering because they are constantly switching between black and white whenever the mouse is pressed in the shape. If you hold the mouse down in the shapes, you are satisfying one or the other colour changing conditions on each screen refresh, hence the flicker. Instead, you want a situation where you only change the square colour if it is the same as before the mouse button was pressed:

```auto
# When no mouse button is pressed, store the square colours
if mouse.getPressed()[0] == 0:
    fills = [R1.fillColor, R2.fillColor]

for index, square in enumerate([R1, R2]):
    # If mouse pressed in square, match current square to square stored in fills list
    # Check if the colour has not changed. If it has not changed, change the colour of the square 
    # that contains the mouse click 
    if mouse.isPressedIn(square) and fills[index] == 'white':
        square.fillColor = 'black'

    if mouse.isPressedIn(square) and fills[index] == 'black':
        square.fillColor = 'white'

```

---

_[View the full topic](https://discourse.psychopy.org/t/stimuli-changes-colour-when-clicked-but-flickering-and-not-responding-immediately/9118)._
