Initialize the sketch with the quit handler. Initialize the sketch with the quit handler such that, if there is no known crash, the application will not exit on its own if this is the first quit attempt. @param sketch The sketch whose quit handler callback should be set.
(final PApplet sketch)
| 61 | * @param sketch The sketch whose quit handler callback should be set. |
| 62 | */ |
| 63 | static public void init(final PApplet sketch) { |
| 64 | getDesktop().setQuitHandler((event, quitResponse) -> { |
| 65 | sketch.exit(); |
| 66 | |
| 67 | boolean noKnownCrash = PApplet.uncaughtThrowable == null; |
| 68 | |
| 69 | if (noKnownCrash && !attemptedQuit) { // haven't tried yet |
| 70 | quitResponse.cancelQuit(); // tell OS X we'll handle this |
| 71 | attemptedQuit = true; |
| 72 | } else { |
| 73 | quitResponse.performQuit(); // just force it this time |
| 74 | } |
| 75 | }); |
| 76 | } |
| 77 | |
| 78 | |
| 79 | /** |
nothing calls this directly
no test coverage detected