From 2874f2c4b4e2731be1b608880631de1c94b506ad Mon Sep 17 00:00:00 2001 From: benfry Date: Fri, 3 Nov 2006 22:58:21 +0000 Subject: [PATCH] fix drag and drop from bouncing back on osx --- app/Editor.java | 24 ++++++++++++++++++++++-- app/Sketch.java | 6 ++++-- todo.txt | 34 ++++++++++++++++++++++++++-------- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/app/Editor.java b/app/Editor.java index 70053afbe..5968892ea 100644 --- a/app/Editor.java +++ b/app/Editor.java @@ -174,8 +174,14 @@ public class Editor extends JFrame // doesn't matter when this is created, just make it happen at some point //find = new FindReplace(Editor.this); - Container pain = getContentPane(); + //Container pain = getContentPane(); + //pain.setLayout(new BorderLayout()); + // for rev 0120, placing things inside a JPanel because + Container contentPain = getContentPane(); + contentPain.setLayout(new BorderLayout()); + JPanel pain = new JPanel(); pain.setLayout(new BorderLayout()); + contentPain.add(pain, BorderLayout.CENTER); Box box = Box.createVerticalBox(); Box upper = Box.createVerticalBox(); @@ -237,6 +243,17 @@ public class Editor extends JFrame listener = new EditorListener(this, textarea); pain.add(box); + pain.setTransferHandler(new TransferHandler() { + + public boolean canImport(JComponent dest, DataFlavor[] flavors) { + // claim that we can import everything + return true; + } + + public boolean importData(JComponent src, Transferable transferable) { + DataFlavor[] flavors = transferable.getTransferDataFlavors(); + + /* DropTarget dt = new DropTarget(this, new DropTargetListener() { public void dragEnter(DropTargetDragEvent event) { @@ -264,6 +281,7 @@ public class Editor extends JFrame Transferable transferable = event.getTransferable(); DataFlavor flavors[] = transferable.getTransferDataFlavors(); + */ int successful = 0; for (int i = 0; i < flavors.length; i++) { @@ -286,7 +304,7 @@ public class Editor extends JFrame File parent = file.getParentFile(); if (name.equals(parent.getName())) { handleOpenFile(file); - return; + return true; } } @@ -298,6 +316,7 @@ public class Editor extends JFrame } catch (Exception e) { e.printStackTrace(); + return false; } } @@ -310,6 +329,7 @@ public class Editor extends JFrame } else { message(successful + " files added to the sketch."); } + return true; } }); } diff --git a/app/Sketch.java b/app/Sketch.java index cfd45ceff..ad64d503b 100644 --- a/app/Sketch.java +++ b/app/Sketch.java @@ -1457,8 +1457,10 @@ public class Sketch { } errorLine -= code[errorFile].preprocOffset; - throw new RunnerException(re.getMessage(), errorFile, - errorLine, re.getColumn()); + String msg = re.getMessage(); + //System.out.println("msg is " + msg); + throw new RunnerException(msg, errorFile, + errorLine, re.getColumn()); } catch (antlr.TokenStreamRecognitionException tsre) { // while this seems to store line and column internally, diff --git a/todo.txt b/todo.txt index 4953273d6..da4a42eb2 100644 --- a/todo.txt +++ b/todo.txt @@ -3,6 +3,30 @@ X add a note saying that changing the font size requires restart X trying out quaqua look and feel on the mac, improve how things look X trying the gtk+ look and feel for linux +X drag & drop on the mac snaps back as if it didn't work +_ does this also happen on windows? +_ are there better classes to use inside the com.apple classes? +_ including the number of items would be especially nice +_ file a bug for this stuff + +// using the awt filedialog instead +// http://lists.apple.com/archives/java-dev/2003/Jul/msg00243.html +FileDialog d = new FileDialog(parent, title, FileDialog.LOAD); +String prop = "apple.awt.fileDialogForDirectories"; +System.setProperty(prop, "true"); +d.show(); +System.setProperty(prop, "false"); +Personally I subclassed FileDialog and do the gymnastic above in the overriden +show() method. + +_ figure out how to cancel 'save changes' on macosx and windows +_ macosx handleQuit seems to force termination (at least on 1.3) +_ http://developer.apple.com/qa/qa2001/qa1187.html +_ http://dev.processing.org/bugs/show_bug.cgi?id=32 + +_ changing font size in editor not updating all font objects +_ particularly after backspace + _ macosx having trouble finding monaco _ changing font size, _ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1160057791 @@ -329,6 +353,8 @@ hacked for fix, needs real fix _ NullPointerException on unterminated comment at end of code _ and OutOfMemoryError and weird lockup _ http://dev.processing.org/bugs/show_bug.cgi?id=16 +_ also OutOfMemoryError if a quote is not terminated +_ _ preprocessor error if last line of code is a comment with no CR after it, _ an OutOfMemoryError wants to happen, _ but right now there's a hack to add a CR in PdePreprocessor @@ -373,9 +399,6 @@ _ rename/saveas doesn't properly have its focus set _ under windows, immediately typing after rename doesn't select _ the whole thing is selected, but not directly editable _ http://dev.processing.org/bugs/show_bug.cgi?id=31 -_ figure out how to cancel 'save changes' on macosx and windows -_ macosx handleQuit seems to force termination (at least on 1.3) -_ http://dev.processing.org/bugs/show_bug.cgi?id=32 _ dim edit menus as appropriate during selection/no selection/etc _ http://dev.processing.org/bugs/show_bug.cgi?id=33 _ Ctrl-Z will undo, but not scroll to where the undo happens. @@ -904,11 +927,6 @@ _ should be using a menu factory to create menubar for all sub-windows _ http://developer.apple.com/technotes/tn/tn2042.html _ and the general warning dialogs are just ass ugly _ (i.e. we really need those replacements for JOptionPane) -_ drag & drop on the mac snaps back as if it didn't work -_ does this also happen on windows? -_ are there better classes to use inside the com.apple classes? -_ including the number of items would be especially nice -_ file a bug for this stuff _ would be nice to have macosx packaged up as a single .app file _ should recommend that people install libraries into their sketchbook _ set nice background for disk image on macosx