Skip to content

Commit

Permalink
Create option to disable quitting the app on cmd-q
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Gassen committed Jul 6, 2016
1 parent 8097ac9 commit 7d0d46d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/java/de/codecentric/centerdevice/MenuToolkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ public void autoAddWindowMenuItems(Menu menu) {
StageHelper.getStages().addListener(new WindowMenuUpdateListener(menu));
}

public void setForceQuitOnCmdQ(boolean forceQuit) {
applicationAdapter.setForceQuitOnCmdQ(forceQuit);
}

protected Menu extractApplicationMenu(MenuBar menuBar) {
return menuBar.getMenus().get(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class MacApplicationAdapter {

private Application app;

private boolean forceQuitOnCmdQ = true;

public MacApplicationAdapter() throws ReflectiveOperationException {
app = Application.GetApplication();

Expand All @@ -39,6 +41,12 @@ public void quit() {
if (eh != null) {
eh.handleQuitAction(Application.GetApplication(), System.nanoTime());
}
Platform.exit();
if (forceQuitOnCmdQ) {
Platform.exit();
}
}

public void setForceQuitOnCmdQ(boolean forceQuit) {
this.forceQuitOnCmdQ = forceQuit;
}
}

0 comments on commit 7d0d46d

Please sign in to comment.