# MousePressed : select only item in front

**URL:** <https://discourse.processing.org/t/mousepressed-select-only-item-in-front/24936>\
**Category:** Coding Questions\
**Created:** [October 26, 2020, 9:59pm UTC](https://discourse.processing.org/t/mousepressed-select-only-item-in-front/24936 "2020-10-26T21:59:45Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [October 27, 2020, 10:54pm UTC](https://discourse.processing.org/t/mousepressed-select-only-item-in-front/24936/5 "2020-10-27T22:54:40Z")

</div>

Hello,

Try this and it should lead to a solution for you:

```auto
function mousePressed() 
  {
  if (bubble1.inside(mouseX, mouseY)) 
    {
    bubble1.clicked()
    print("b1");
    }

  if (bubble2.inside(mouseX, mouseY)) 
    {
    bubble2.clicked()
    print("b2");
    }
  }

```

`:)`

---

_[View the full topic](https://discourse.processing.org/t/mousepressed-select-only-item-in-front/24936)._
