I’m trying to execute code when a sketch stops. I’ve been using this as a guide (Run code on exit - Processing Forum). There seems to be three scenarios that this can occur 1) Closing the window 2) Hitting the ESC key 3) Pressing the stop button in Processing. I have the first two working but not the stop button. My guess is that this is not calling stop()/exit() but instead some sort of killall process - but searching I can’t find what this is. How do I capture this or is it impossible because it’s from another window?
Here is what I have. I’m testing in Processing 4.3 on OSX.
There is an exit() function is the code i posted and as I said this does not work on Processing 4.3 on OSX. Stopping the sketch with the stop button does not trigger it.
may I ask you, why you use the Stop-Button ? This button is meant to be to force kill your application. Usually one uses the close button on the sketch window, or uses a key handler for ESC key to close the window…
So briefly spoken, you can’t catch the Stop-Button event as it kills the underlying VM which is your sketch running…
For regular closing events you can use the method shown above …
I’m trying to catch all possible scenarios of the sketch stopping as my original post mentioned.
You mentioned the typical ways of stopping a sketch. The ESC key doesn’t seem to work properly on OSX with Processing 4.3 anymore. It used to but now it stops the sketch but leaves the window open.
This button is meant to be to force kill your application…you can’t catch the Stop-Button event
This answers my question - it is not possible to catch that kill all event.