# Application hangs when mouse is moved

**URL:** <https://discourse.processing.org/t/application-hangs-when-mouse-is-moved/6946>\
**Category:** Coding Questions\
**Created:** [December 28, 2018, 8:15am UTC](https://discourse.processing.org/t/application-hangs-when-mouse-is-moved/6946 "2018-12-28T08:15:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iampadik](https://avatars.discourse-cdn.com/v4/letter/i/e56c9b/32.png) [@iampadik](https://discourse.processing.org/u/iampadik)\
**Post date:** [December 28, 2018, 8:15am UTC](https://discourse.processing.org/t/application-hangs-when-mouse-is-moved/6946/1 "2018-12-28T08:15:41Z")

</div>

Hello people. A novice here.My application hangs as soon as my mouse moves and I have to restart the application. Whereas I don’t have the function mouseMoved in my code anywhere. If I keep the mouse steady , application runs good (acquiring data and plotting) and I can click buttons further and keep the application running perfectly as it should.

Could you guys help me with what could be the reason.

Please suggest if I should post this under other categories as well.

I am using Processing 3 on Windows 7.

---

<div class="post-metadata">

**Author:** ![Architector\_4](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/architector_4/32/813_2.png) [@Architector\_4](https://discourse.processing.org/u/Architector_4)\
**Post date:** [December 28, 2018, 8:40am UTC](https://discourse.processing.org/t/application-hangs-when-mouse-is-moved/6946/2 "2018-12-28T08:40:37Z")

</div>

There could be millions of possible reasons for this, and we can’t tell which one it is without any code.

My suggestion is for you to put something like `rect(10,sin((float)millis()/1000*PI)*50+25,50,50);` at the end of `void draw()` to be able to always tell if it hangs or not, and then **start deleting chunks of code** until you get a _“minimum viable example”,_ i.e. a set of code containing minimum lines of code that shows your problem, i.e. starts hanging on mouse movement. Make sure to back your project up first.

---

<div class="post-metadata">

**Author:** ![iampadik](https://avatars.discourse-cdn.com/v4/letter/i/e56c9b/32.png) [@iampadik](https://discourse.processing.org/u/iampadik)\
**Post date:** [December 28, 2018, 9:15am UTC](https://discourse.processing.org/t/application-hangs-when-mouse-is-moved/6946/3 "2018-12-28T09:15:05Z")

</div>

Thanks Architector for your prompt reply. I did put that line you suggested at the bottom of void draw() and it does get stuck as I move my mouse. Let me delete parts of code one by one and see which part is really causing the problem. If it still persists, I will share my code for you to have a look. 🙂 Thanks again.

---

<div class="post-metadata">

**Author:** ![iampadik](https://avatars.discourse-cdn.com/v4/letter/i/e56c9b/32.png) [@iampadik](https://discourse.processing.org/u/iampadik)\
**Post date:** [December 29, 2018, 2:50pm UTC](https://discourse.processing.org/t/application-hangs-when-mouse-is-moved/6946/4 "2018-12-29T14:50:50Z")

</div>

Thanks again Architector for taking my attention to reviewing the code. It was a simple mistake. I used mouseX and mouseY values in if () condition and used it in a loop. ofc it won’t work further as i move my mouse… 😑

I shall be careful to avoid such simple mistakes…
