From dc83850034b17e3c5c2110bd2c9218950eeb0bb6 Mon Sep 17 00:00:00 2001 From: benfry Date: Thu, 16 Nov 2006 21:16:42 +0000 Subject: [PATCH] fix the close dialog for macosx, also fix bug #440 that was closing the app on cancel --- app/Editor.java | 89 ++++++++++++++++++++++++++++++------------------- todo.txt | 9 +++-- 2 files changed, 62 insertions(+), 36 deletions(-) diff --git a/app/Editor.java b/app/Editor.java index a2326f6ac..399eac433 100644 --- a/app/Editor.java +++ b/app/Editor.java @@ -26,7 +26,7 @@ package processing.app; import processing.app.syntax.*; import processing.app.tools.*; -import processing.core.PConstants; +import processing.core.*; import java.awt.*; import java.awt.datatransfer.*; @@ -686,7 +686,6 @@ public class Editor extends JFrame item = new JMenuItem("Create Font..."); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - //new CreateFont().show(sketch.dataFolder); new CreateFont(Editor.this).show(); } }); @@ -1369,49 +1368,71 @@ public class Editor extends JFrame String prompt = "Save changes to " + sketch.name + "? "; if (checkModifiedMode != HANDLE_QUIT) { - // if the user is not quitting, then use the nicer + // if the user is not quitting, then use simpler nicer // dialog that's actually inside the p5 window. status.prompt(prompt); } else { - // if the user selected quit, then this has to be done with - // a JOptionPane instead of internally in the editor. - // TODO this is actually just a bug to be fixed. + if (!Base.isMacOS() || PApplet.javaVersion < 1.5f) { + int result = + JOptionPane.showConfirmDialog(this, prompt, "Quit", + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE); - // macosx java kills the app even though cancel might get hit - // so the cancel button is (temporarily) left off - // this may be treated differently in macosx java 1.4, - // but 1.4 isn't currently stable enough to use. + if (result == JOptionPane.YES_OPTION) { + handleSave(true); + checkModified2(); - // turns out windows has the same problem (sometimes) - // disable cancel for now until a fix can be found. + } else if (result == JOptionPane.NO_OPTION) { + checkModified2(); + } + // cancel is ignored altogether - int result = - JOptionPane.showConfirmDialog(this, prompt, "Quit", - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE); + } else { + // This code is disabled unless Java 1.5 is being used on Mac OS X + // because of a Java bug that prevents the initial value of the + // dialog from being set properly (at least on my MacBook Pro). + // The bug causes the "Don't Save" option to be the highlighted, + // blinking, default. This sucks. But I'll tell you what doesn't + // suck--workarounds for the Mac and Apple's snobby attitude about it! - /* - Object[] options = { "Yes", "No" }; - int result = JOptionPane.showOptionDialog(this, - prompt, - "Quit", - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE, - null, - options, - options[0]); - */ + // adapted from the quaqua guide + // http://www.randelshofer.ch/quaqua/guide/joptionpane.html + JOptionPane pane = + new JOptionPane(" " + + " " + + "Do you want to save changes to this sketch
" + + " before closing?
" + + "

If you don't save, your changes will be lost.", + JOptionPane.QUESTION_MESSAGE); - if (result == JOptionPane.YES_OPTION) { - handleSave(true); - checkModified2(); + String[] options = new String[] { + "Save", "Cancel", "Don't Save" + }; + pane.setOptions(options); - } else if (result == JOptionPane.NO_OPTION) { - checkModified2(); // though this may just quit + // highlight the safest option ala apple hig + pane.setInitialValue(options[0]); - } else if (result == JOptionPane.CANCEL_OPTION) { - // ignored + // on macosx, setting the destructive property places this option + // away from the others at the lefthand side + pane.putClientProperty("Quaqua.OptionPane.destructiveOption", + new Integer(2)); + + JDialog dialog = pane.createDialog(this, null); + dialog.show(); + + Object result = pane.getValue(); + if (result == options[0]) { // save (and quit) + handleSave(true); + checkModified2(); + + } else if (result == options[2]) { // don't save (still quit) + checkModified2(); + } } } } diff --git a/todo.txt b/todo.txt index 7dae652c9..cea6079b3 100644 --- a/todo.txt +++ b/todo.txt @@ -13,6 +13,8 @@ X right now goes to begin/end of line.. should be begin/end of file? X change to begin/end of file, and use cmd or alt, based on platform X cmd-{ and cmd-} no longer work after the menu is shown X http://dev.processing.org/bugs/show_bug.cgi?id=402 +X clicking "cancel" on close still quitting the app +X http://dev.processing.org/bugs/show_bug.cgi?id=440 fixed earlier or wontfix X double-click only selects part of underscored word @@ -32,8 +34,9 @@ X a moveto *inside* a shape will be treated as a lineto X had to fix this X implement polyline -_ clicking "cancel" on close still quitting the app (suspect java 1.5) -_ http://dev.processing.org/bugs/show_bug.cgi?id=440 + +X updated to antlr 2.7.7 +_ added log4j (for the autoformatter) _ applet sizing issues with external vm _ could this possibly be related to the linux bug? @@ -55,6 +58,8 @@ For 2.0 LIBRARIES / svg +_ support for text (shouldn't be too bad, use createFont) +_ honor the designation for layers that are marked 'hidden' _ get entity tags working in xml library _ try enabling blending modes _ add better support for attributes buried in styles (support ai9/10/11)