Unter macOS auf Cmd+Q reagieren
This commit is contained in:
parent
60ed045986
commit
7f1d9012e9
|
@ -242,6 +242,11 @@ public class Zeichenmaschine extends Constants {
|
||||||
public Zeichenmaschine( int width, int height, String title, boolean run_once ) {
|
public Zeichenmaschine( int width, int height, String title, boolean run_once ) {
|
||||||
LOG.info("Starting " + APP_NAME + " " + APP_VERSION);
|
LOG.info("Starting " + APP_NAME + " " + APP_VERSION);
|
||||||
|
|
||||||
|
// Register Cmd+Q on macOS
|
||||||
|
if( Constants.MACOS ) {
|
||||||
|
System.setProperty("apple.eawt.quitStrategy", "CLOSE_ALL_WINDOWS");
|
||||||
|
}
|
||||||
|
|
||||||
// Erstellen der Leinwand
|
// Erstellen der Leinwand
|
||||||
canvas = new Zeichenleinwand(width, height);
|
canvas = new Zeichenleinwand(width, height);
|
||||||
|
|
||||||
|
@ -533,9 +538,7 @@ public class Zeichenmaschine extends Constants {
|
||||||
running = false;
|
running = false;
|
||||||
terminateImediately = true;
|
terminateImediately = true;
|
||||||
quitAfterShutdown = true;
|
quitAfterShutdown = true;
|
||||||
if( state != Options.AppState.QUITING ) {
|
mainThread.interrupt();
|
||||||
mainThread.interrupt();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
quit(true);
|
quit(true);
|
||||||
}
|
}
|
||||||
|
@ -570,13 +573,15 @@ public class Zeichenmaschine extends Constants {
|
||||||
*/
|
*/
|
||||||
public final void quit( boolean exit ) {
|
public final void quit( boolean exit ) {
|
||||||
state = Options.AppState.QUITING;
|
state = Options.AppState.QUITING;
|
||||||
frame.setVisible(false);
|
TaskRunner.invokeLater(() -> {
|
||||||
canvas.dispose();
|
frame.setVisible(false);
|
||||||
frame.dispose();
|
canvas.dispose();
|
||||||
|
frame.dispose();
|
||||||
|
|
||||||
if( exit ) {
|
if( exit ) {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue