3131
3232
3333/**
34- * Deal with issues related to thinking differently. This handles the basic
35- * Mac OS X menu commands (and apple events) for open, about, prefs, etc.
34+ * Deal with issues related to thinking differently.
35+ *
36+ * We have to register a quit handler to safely shut down the sketch,
37+ * otherwise OS X will just kill the sketch when a user hits Cmd-Q.
38+ * In addition, we have a method to set the dock icon image so we look more
39+ * like a native application.
3640 *
3741 * This is a stripped-down version of what's in processing.app.platform to fix
3842 * <a href="https://github.com/processing/processing/issues/3301">3301</a>.
3943 */
4044public class ThinkDifferent {
4145
42- // pseudo-singleton model; no point in making multiple instances
43- // of the EAWT application or our adapter
44- // private static ThinkDifferent adapter;
4546 // http://developer.apple.com/documentation/Java/Reference/1.4.2/appledoc/api/com/apple/eawt/Application.html
4647 private static Application application ;
4748
48- // reference to the app where the existing quit, about, prefs code is
49- //private Base base;
50-
5149 // True if user has tried to quit once. Prevents us from canceling the quit
52- // call if the sketch is held up for some reason.
50+ // call if the sketch is held up for some reason, like an exception that's
51+ // managed to put the sketch in a bad state.
5352 static boolean attemptedQuit ;
5453
5554
5655 static public void init (final PApplet sketch ) {
5756 if (application == null ) {
5857 application = Application .getApplication ();
5958 }
60- // if (adapter == null) {
61- // adapter = new ThinkDifferent(); //base);
62- // }
63-
64- // Keeping these around in case we decide we want to add generic handlers
65- // for these other features. Not sure how this affects JavaFX.
66- /*
67- application.setAboutHandler(new AboutHandler() {
68- public void handleAbout(AboutEvent ae) {
69- new About(null);
70- }
71- });
72-
73- application.setPreferencesHandler(new PreferencesHandler() {
74- public void handlePreferences(PreferencesEvent arg0) {
75- base.handlePrefs();
76- }
77- });
78-
79- application.setOpenFileHandler(new OpenFilesHandler() {
80- public void openFiles(OpenFilesEvent event) {
81- for (File file : event.getFiles()) {
82- base.handleOpen(file.getAbsolutePath());
83- }
84- }
85- });
86-
87- application.setPrintFileHandler(new PrintFilesHandler() {
88- public void printFiles(PrintFilesEvent event) {
89- // TODO not yet implemented
90- }
91- });
92- */
9359
9460 application .setQuitHandler (new QuitHandler () {
9561 public void handleQuitRequestWith (QuitEvent event , QuitResponse response ) {
@@ -102,23 +68,6 @@ public void handleQuitRequestWith(QuitEvent event, QuitResponse response) {
10268 }
10369 }
10470 });
105-
106- /*
107- // Set the menubar to be used when nothing else is open.
108- JMenuBar defaultMenuBar = new JMenuBar();
109- JMenu fileMenu = buildFileMenu(base);
110- defaultMenuBar.add(fileMenu);
111- // This is kind of a gross way to do this, but the alternatives? Hrm.
112- Base.defaultFileMenu = fileMenu;
113-
114- // if (PApplet.javaVersion <= 1.6f) { // doesn't work on Oracle's Java
115- try {
116- application.setDefaultMenuBar(defaultMenuBar);
117-
118- } catch (Exception e) {
119- e.printStackTrace(); // oh well, never mind
120- }
121- */
12271 }
12372
12473
0 commit comments