Hi @Thundercat,
edited my code … sure, other way around …
In your inital version it stucks in an endless loop, so I just want to get rid of that.
Your question imo leads you in the wrong direction…
If you’re in the while loop on a single thread, nothing would can’t change the attribute, so it never gets true and hence nothing in you program would proceed further code.
The question is, do you really need that while loop and why ? (maybe the while loop is the draw function in your case, if it is meant as ie. a game loop with event handling)
s.th similar like this …
void draw() {
...
for (Button b:buttons) {
if (mousePressed && b.isPressed(mouseX,mouseY)) {
// do something for button b
}
}
...
}
If you want an event driven approach, you should implement s.th like mentioned above by observer pattern, which notifies (calls a function) depending on the event…
Cheers
— mnse