From 6eea3ec46e63721b7780b139852a63da7995841f Mon Sep 17 00:00:00 2001 From: benfry Date: Tue, 27 Mar 2012 14:27:58 +0000 Subject: [PATCH] trying to debug window focus issue --- app/src/processing/app/Editor.java | 10 +++-- app/src/processing/app/Sketch.java | 37 ++++++++++--------- .../processing/app/syntax/JEditTextArea.java | 16 ++++---- todo.txt | 4 ++ 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 38fc9cc69..71390804b 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -265,9 +265,13 @@ public abstract class Editor extends JFrame implements RunnerListener { // May not be necessary, but helps avoid random situations with // the editor not being able to request its own focus. addWindowFocusListener(new WindowAdapter() { - public void windowGainedFocus(WindowEvent e) { - textarea.requestFocusInWindow(); - } + public void windowGainedFocus(WindowEvent e) { + textarea.requestFocusInWindow(); + } + +// public void windowLostFocus(WindowEvent e) { +// System.out.println("lost focus, should we tell the text area?"); +// } }); // Open the document that was passed in diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index fbc9a9bcc..e01adcaad 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -709,7 +709,9 @@ public class Sketch { String newParentDir = null; String newName = null; - /* + if (false) { + // The Swing file chooser has some upside (i.e. fixes an OS X focus + // traversal bug) bug is super ugly and not OS native. JFileChooser fc = new JFileChooser(); fc.setDialogTitle("Save sketch folder as..."); if (isReadOnly() || isUntitled()) { @@ -727,25 +729,24 @@ public class Sketch { newParentDir = selection.getParent(); newName = selection.getName(); } - */ - - // get new name for folder - FileDialog fd = new FileDialog(editor, - "Save sketch folder as...", - FileDialog.SAVE); - if (isReadOnly() || isUntitled()) { - // default to the sketchbook folder - fd.setDirectory(Preferences.get("sketchbook.path")); } else { - // default to the parent folder of where this was - fd.setDirectory(folder.getParent()); + // get new name for folder + FileDialog fd = new FileDialog(editor, + "Save sketch folder as...", + FileDialog.SAVE); + if (isReadOnly() || isUntitled()) { + // default to the sketchbook folder + fd.setDirectory(Preferences.get("sketchbook.path")); + } else { + // default to the parent folder of where this was + fd.setDirectory(folder.getParent()); + } + String oldName = folder.getName(); + fd.setFile(oldName); + fd.setVisible(true); + newParentDir = fd.getDirectory(); + newName = fd.getFile(); } - String oldName = folder.getName(); - fd.setFile(oldName); - - fd.setVisible(true); - newParentDir = fd.getDirectory(); - newName = fd.getFile(); // user canceled selection if (newName == null) return false; diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java index 2ac9493cc..059d6a85e 100644 --- a/app/src/processing/app/syntax/JEditTextArea.java +++ b/app/src/processing/app/syntax/JEditTextArea.java @@ -176,13 +176,13 @@ public class JEditTextArea extends JComponent } - /** - * Returns if this component can be traversed by pressing - * the Tab key. This returns false. - */ - // public final boolean isManagingFocus() { - // return true; - // } +// /** +// * Returns if this component can be traversed by pressing +// * the Tab key. This returns false. (removing b/c superclass returns false) +// */ +// public final boolean isManagingFocus() { +// return false; +// } /** * Returns the object responsible for painting this text area. @@ -1822,7 +1822,7 @@ public class JEditTextArea extends JComponent * Inserts the clipboard contents into the text. */ public void paste() { - System.out.println("focus owner is: " + isFocusOwner()); +// System.out.println("focus owner is: " + isFocusOwner()); if (editable) { Clipboard clipboard = getToolkit().getSystemClipboard(); try { diff --git a/todo.txt b/todo.txt index 2b5b3c446..b6171af40 100644 --- a/todo.txt +++ b/todo.txt @@ -1542,6 +1542,10 @@ _ http://dev.processing.org/bugs/show_bug.cgi?id=1567 DIST / Mac OS X +_ cut/copy/paste while saving a sketch on goes to the editor, not save dialog +_ http://code.google.com/p/processing/issues/detail?id=997 +_ problem with focus traversal and native windows on OS X +_ using JFileChooser fixes the problem (but is ugly) _ the word from apple on Info.plist setup DO NOT USE "JVMArchs". It is deprecated, and manually overrides the natural architecture launching and ordering that LaunchServices does, including accommodating the 32-bit checkbox in the Get Info window. _ instead of "show sketch folder" method, use: