# 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:** 8

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [October 28, 2020, 2:31pm UTC](https://discourse.processing.org/t/mousepressed-select-only-item-in-front/24936/8 "2020-10-28T14:31:56Z")

</div>

> [@Chrisir](#):
>
> It is necessary in the constructor, but not in **clicked()** or **show()**.

> [@Converting my Processing code to p5.js (ArrayList + others!)](https://discourse.processing.org/t/converting-my-processing-code-to-p5-js-arraylist-others/14936/3):
>
> That’s not how we define classes’ constructor, methods & fields under JS syntax! You should read the JS reference for it: Also, there’s no ArrayList either. We use JS arrays instead: And while in Java we can generally omit the keyword this before accessing a class member, in JS it’s mandatory: [[This Dot - Daniel Shiffman (Coding Train)] ](https://www.youtube.com/watch?v=M5d7vygUPoQ) Now w/ all the info above, here’s a partial but proper JS conversion of your class ParticleSystem: class ParticleSystem { constructor(posit…

---

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