fixes to re-enable sketchbook prompt, also shift-new to do oppo behavior

This commit is contained in:
benfry
2004-06-22 02:27:00 +00:00
parent 9113fe2e1c
commit b2dbffd3a8
5 changed files with 24 additions and 26 deletions

View File

@@ -65,6 +65,7 @@ public class PdeEditor extends JFrame
static final int HANDLE_QUIT = 3;
int checkModifiedMode;
String handleOpenPath;
boolean handleNewShift;
//String handleSaveAsPath;
//String openingName;
@@ -462,7 +463,7 @@ public class PdeEditor extends JFrame
item = newJMenuItem("New sketch", 'N');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleNew();
handleNew(false);
}
});
menu.add(item);
@@ -1164,9 +1165,13 @@ public class PdeEditor extends JFrame
/**
* New was called (by buttons or by menu), first check modified
* and if things work out ok, handleNew2() will be called.
*
* If shift is pressed when clicking the toolbar button, then
* force the opposite behavior from sketchbook.prompt's setting
*/
public void handleNew() {
public void handleNew(boolean shift) {
doStop();
handleNewShift = shift;
checkModified(HANDLE_NEW);
}
@@ -1178,7 +1183,7 @@ public class PdeEditor extends JFrame
*/
protected void handleNew2(boolean startup) {
try {
String pdePath = sketchbook.handleNew(startup);
String pdePath = sketchbook.handleNew(startup, handleNewShift);
if (pdePath != null) handleOpen2(pdePath);
} catch (IOException e) {

View File

@@ -340,7 +340,7 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener {
case RUN: editor.handleRun(e.isShiftDown()); break;
case STOP: setState(RUN, INACTIVE, true); editor.handleStop(); break;
case OPEN: setState(OPEN, INACTIVE, true); break;
case NEW: editor.handleNew(); break;
case NEW: editor.handleNew(e.isShiftDown()); break;
case SAVE: editor.handleSave(); break;
case EXPORT: editor.handleExport(); break;
}

View File

@@ -185,7 +185,6 @@ public class PdePreferences extends JComponent {
// [ ] Prompt for name and folder when creating new sketch
/*
sketchPromptBox =
new JCheckBox("Prompt for name when opening or creating a sketch");
pain.add(sketchPromptBox);
@@ -193,7 +192,6 @@ public class PdePreferences extends JComponent {
sketchPromptBox.setBounds(left, top, d.width, d.height);
right = Math.max(right, left + d.width);
top += d.height + GUI_BETWEEN;
*/
// Sketchbook location:
@@ -343,16 +341,6 @@ public class PdePreferences extends JComponent {
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((screen.width - wide) / 2,
(screen.height - high) / 2);
//
/*
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
frame.hide();
}
});
*/
}
@@ -378,7 +366,7 @@ public class PdePreferences extends JComponent {
//editor.setExternalEditor(getBoolean("editor.external"));
// put each of the settings into the table
//setBoolean("sketchbook.prompt", sketchPromptBox.isSelected());
setBoolean("sketchbook.prompt", sketchPromptBox.isSelected());
set("sketchbook.path", sketchbookLocationField.getText());
setBoolean("export.library", exportLibraryBox.isSelected());
setBoolean("editor.external", externalEditorBox.isSelected());
@@ -391,7 +379,7 @@ public class PdePreferences extends JComponent {
editor.hide();
// set all settings entry boxes to their actual status
//sketchPromptBox.setSelected(getBoolean("sketchbook.prompt"));
sketchPromptBox.setSelected(getBoolean("sketchbook.prompt"));
sketchbookLocationField.setText(get("sketchbook.path"));
exportLibraryBox.setSelected(getBoolean("export.library"));
externalEditorBox.setSelected(getBoolean("editor.external"));

View File

@@ -100,10 +100,14 @@ public class PdeSketchbook {
* Handle creating a sketch folder, return its base .pde file
* or null if the operation was cancelled.
*/
public String handleNew(boolean startup) throws IOException {
public String handleNew(boolean startup,
boolean shift) throws IOException {
File newbieDir = null;
String newbieName = null;
boolean prompt = PdePreferences.getBoolean("sketchbook.prompt");
if (shift) prompt = !prompt; // reverse behavior if shift is down
// no sketch has been started, don't prompt for the name if it's
// starting up, just make the farker. otherwise if the person hits
// 'cancel' i'd have to add a thing to make p5 quit, which is silly.
@@ -112,8 +116,10 @@ public class PdeSketchbook {
// unless, ermm, they user tested it and people preferred that as
// a way to get started. shite. now i hate myself.
//
//if (PdePreferences.getBoolean("sketchbook.prompt") && !startup) {
if (!startup) {
if (startup) prompt = false;
if (prompt) {
//if (!startup) {
// prompt for the filename and location for the new sketch
FileDialog fd = new FileDialog(editor, //new Frame(),

View File

@@ -103,12 +103,15 @@ X appendText is disabled due to NullPointerEx on startup
X empty the console when a new sketch is opened
X if console.auto_clear is set to true, will clear on run and open
X http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1086972918
X maybe bring back the prompt option for "new sketch"
X sometimes nice just to have it create an unnamed sketch quickly
X shift-new will always prompt with filedialog
_ dashes shouldn't be allowed in filenames for sketches
_ actually, lost the naming stuff because now using FileDialog
_ this also needs to be checked when building the sketch menu
_ make export save to multiple files
_ don't force everything into a single .jar on export
_ what happens when the .pde file isn't named
_ the same as the enclosing folder?
@@ -126,10 +129,6 @@ _ running present mode with a bug in the program hoses things
_ make sure the program compiles before starting present mode
_ re-implement history
_ maybe bring back the prompt option for "new sketch"
_ sometimes nice just to have it create an unnamed sketch quickly
_ shift-new will always prompt with filedialog
now implemented for [url=http://processing.org/discourse/yabb/YaBB.cgi?board=Collaboration;action=display;num=1084285917]megabucket[/url].