# How to use mouseClicked to only effect one object in ArrayList?

**URL:** <https://discourse.processing.org/t/how-to-use-mouseclicked-to-only-effect-one-object-in-arraylist/22067>\
**Category:** Coding Questions\
**Created:** [June 22, 2020, 3:48pm UTC](https://discourse.processing.org/t/how-to-use-mouseclicked-to-only-effect-one-object-in-arraylist/22067 "2020-06-22T15:48:22Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [June 22, 2020, 4:06pm UTC](https://discourse.processing.org/t/how-to-use-mouseclicked-to-only-effect-one-object-in-arraylist/22067/2 "2020-06-22T16:06:54Z")

</div>

Your Lego class should have a boolean field that sets the state as “currently-being-dragged” so each Lego instance has this field and tehnically only one lego would have this state set to true. I did a demo [here](https://discourse.processing.org/t/change-color-moving/21924/4) recently. Maybe you can sere the approach there and applied it to your use case.

Btw, the code you provide is not enough to see the problem. I suggest you provide a [MCVE](https://stackoverflow.com/help/minimal-reproducible-example) as it will help a ton in these cases.

Kf

---

_[View the full topic](https://discourse.processing.org/t/how-to-use-mouseclicked-to-only-effect-one-object-in-arraylist/22067)._
