Reset mouseIsPressed on window blur by avinxshKD · Pull Request #8559 · processing/p5.js

@avinxshKD please feel free to go ahead with work on this one on 2.0. As you said it's similar to the key one in the other issue. I think only one of these should be done initially to get some feedback.

Why I'm a bit cautious: Although the tabbing-away behavior is not intuitive and buggy, its also not a regression (if I understood it well), so I want to be sure that changing the existing behavior doesn't have surprising side-effects. (Eg, in more complex uses, like in P5Live, which might rely on current behavior being stable - this is just a guess, I am not sure if there are side effects) I hope this clarifies why I think it's worth being a bit cautious about this one.

That said, as you write, mouse has no blur handler at all right now, so I think this is a better place to start.

Thanks @ksen0, kept it minimal for exactly that reason. Only resets mouseIsPressed, nothing else. mouseButton is untouched so any code branching on which button was held still sees the same state it did before. The change is 4 lines in pointer.js's presetup ...same { signal: this._removeSignal } cleanup pattern the other listeners there already use, so no new teardown logic needed either.

If there are side effects to watch for, happy to add a note in the PR description calling it out explicitly so reviewers know what to poke at, lmk