Skip to content

Commit 43c41bf

Browse files
committed
clean up editor toolbar button code a bit, add new messages when shift is pressed
1 parent d128367 commit 43c41bf

File tree

6 files changed

+118
-150
lines changed

6 files changed

+118
-150
lines changed

android/todo.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
X fix problem with windows claiming "does not appear to contain an Android SDK"
33
X add methods to request rendering
44
_ need to deal with fps problems with this model
5+
_ check on multiple pointers work (peter's msg)
56

67

78
P1 this is embarrassing, need to fix ASAP

app/src/processing/app/Base.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,8 @@ public void actionPerformed(ActionEvent e) {
890890

891891
// Add a list of all sketches and subfolders
892892
try {
893-
boolean sketches = addSketches(menu, getSketchbookFolder(), true);
893+
//boolean sketches = addSketches(menu, getSketchbookFolder(), true);
894+
boolean sketches = addSketches(menu, getSketchbookFolder());
894895
if (sketches) menu.addSeparator();
895896
} catch (IOException e) {
896897
e.printStackTrace();
@@ -899,7 +900,8 @@ public void actionPerformed(ActionEvent e) {
899900
//System.out.println("rebuilding examples menu");
900901
// Add each of the subfolders of examples directly to the menu
901902
try {
902-
addSketches(menu, examplesFolder, true);
903+
//addSketches(menu, examplesFolder, true);
904+
addSketches(menu, examplesFolder);
903905
} catch (IOException e) {
904906
e.printStackTrace();
905907
}
@@ -911,7 +913,8 @@ protected void rebuildSketchbookMenu(JMenu menu) {
911913
//new Exception().printStackTrace();
912914
try {
913915
menu.removeAll();
914-
addSketches(menu, getSketchbookFolder(), false);
916+
//addSketches(menu, getSketchbookFolder(), false);
917+
addSketches(menu, getSketchbookFolder());
915918
} catch (IOException e) {
916919
e.printStackTrace();
917920
}
@@ -952,7 +955,8 @@ public void rebuildExamplesMenu(JMenu menu) {
952955
//System.out.println("rebuilding examples menu");
953956
try {
954957
menu.removeAll();
955-
addSketches(menu, examplesFolder, false);
958+
//addSketches(menu, examplesFolder, false);
959+
addSketches(menu, examplesFolder);
956960
} catch (IOException e) {
957961
e.printStackTrace();
958962
}
@@ -965,8 +969,7 @@ public void rebuildExamplesMenu(JMenu menu) {
965969
* should replace the sketch in the current window, or false when the
966970
* sketch should open in a new window.
967971
*/
968-
protected boolean addSketches(JMenu menu, File folder,
969-
final boolean openReplaces) throws IOException {
972+
protected boolean addSketches(JMenu menu, File folder) throws IOException {
970973
// skip .DS_Store files, etc (this shouldn't actually be necessary)
971974
if (!folder.isDirectory()) return false;
972975

@@ -983,7 +986,8 @@ protected boolean addSketches(JMenu menu, File folder,
983986
public void actionPerformed(ActionEvent e) {
984987
String path = e.getActionCommand();
985988
if (new File(path).exists()) {
986-
if (openReplaces) {
989+
// if (openReplaces) {
990+
if ((e.getModifiers() & ActionEvent.SHIFT_MASK) == 0) {
987991
handleOpenReplace(path);
988992
} else {
989993
handleOpen(path);
@@ -1038,7 +1042,8 @@ public void actionPerformed(ActionEvent e) {
10381042
JMenu submenu = new JMenu(list[i]);
10391043
// needs to be separate var
10401044
// otherwise would set ifound to false
1041-
boolean found = addSketches(submenu, subfolder, openReplaces); //, false);
1045+
//boolean found = addSketches(submenu, subfolder, openReplaces); //, false);
1046+
boolean found = addSketches(submenu, subfolder); //, false);
10421047
if (found) {
10431048
menu.add(submenu);
10441049
ifound = true;

app/src/processing/app/Editor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ public void windowDeactivated(WindowEvent e) {
246246
// (har har har.. that was wishful thinking)
247247
listener = new EditorListener(this, textarea);
248248
pain.add(box);
249+
250+
// get shift down/up events so we can show the alt version of toolbar buttons
251+
textarea.addKeyListener(toolbar);
249252

250253
pain.setTransferHandler(new FileDropHandler());
251254

app/src/processing/app/EditorListener.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ public boolean keyPressed(KeyEvent event) {
103103
char c = event.getKeyChar();
104104
int code = event.getKeyCode();
105105

106+
// if (code == KeyEvent.VK_SHIFT) {
107+
// editor.toolbar.setShiftPressed(true);
108+
// }
109+
106110
//System.out.println((int)c + " " + code + " " + event);
107111
//System.out.println();
108112

@@ -455,6 +459,13 @@ public boolean keyPressed(KeyEvent event) {
455459
}
456460
return false;
457461
}
462+
463+
464+
// public boolean keyReleased(KeyEvent event) {
465+
// if (code == KeyEvent.VK_SHIFT) {
466+
// editor.toolbar.setShiftPressed(false);
467+
// }
468+
// }
458469

459470

460471
public boolean keyTyped(KeyEvent event) {

0 commit comments

Comments
 (0)