Skip to content

Commit e7fe15e

Browse files
committed
[WIP] Modify behaviour of OSX close
1 parent 617430a commit e7fe15e

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

app/src/processing/app/Base.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import processing.app.debug.TargetPackage;
4646
import processing.app.debug.TargetPlatform;
4747
import processing.app.helpers.*;
48+
import processing.app.helpers.OSUtils;
4849
import processing.app.helpers.filefilters.OnlyDirs;
4950
import processing.app.helpers.filefilters.OnlyFilesWithExtension;
5051
import processing.app.javax.swing.filechooser.FileNameExtensionFilter;
@@ -921,7 +922,10 @@ public boolean handleClose(Editor editor) {
921922
storeSketches();
922923

923924
// This will store the sketch count as zero
925+
editor.setVisible(false);
926+
editor.dispose();
924927
editors.remove(editor);
928+
925929
try {
926930
Editor.serialMonitor.close();
927931
} catch (Exception e) {
@@ -932,9 +936,10 @@ public boolean handleClose(Editor editor) {
932936
// Save out the current prefs state
933937
PreferencesData.save();
934938

935-
// Since this wasn't an actual Quit event, call System.exit()
936-
System.exit(0);
937-
939+
// Since this wasn't an actual Quit event, call System.exit() (not on OSX)
940+
if (!OSUtils.isMacOS()) {
941+
System.exit(0);
942+
}
938943
} else {
939944
// More than one editor window open,
940945
// proceed with closing the current window.
@@ -976,7 +981,7 @@ public boolean handleQuit() {
976981
// Save out the current prefs state
977982
PreferencesData.save();
978983

979-
if (!OSUtils.hasMacOSStyleMenus()) {
984+
if (!OSUtils.isMacOS()) {
980985
// If this was fired from the menu or an AppleEvent (the Finder),
981986
// then Mac OS X will send the terminate signal itself.
982987
System.exit(0);

app/src/processing/app/macosx/ThinkDifferent.java

+15
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
package processing.app.macosx;
2424

2525
import com.apple.eawt.*;
26+
import com.apple.eawt.AppEvent.AppReOpenedEvent;
27+
2628
import processing.app.Base;
2729
import processing.app.Editor;
2830

@@ -45,6 +47,19 @@ public class ThinkDifferent {
4547

4648
static public void init() {
4749
Application application = Application.getApplication();
50+
51+
application.addAppEventListener(new AppReOpenedListener() {
52+
@Override
53+
public void appReOpened(AppReOpenedEvent aroe) {
54+
try {
55+
Base.INSTANCE.handleNew();
56+
} catch (Exception e) {
57+
// TODO Auto-generated catch block
58+
e.printStackTrace();
59+
}
60+
}
61+
});
62+
4863
application.setAboutHandler(new AboutHandler() {
4964
@Override
5065
public void handleAbout(AppEvent.AboutEvent aboutEvent) {

0 commit comments

Comments
 (0)