diff --git a/processing/app/PdeEditor.java b/processing/app/PdeEditor.java index fe5838016..ea20d8cd7 100644 --- a/processing/app/PdeEditor.java +++ b/processing/app/PdeEditor.java @@ -236,7 +236,7 @@ public class PdeEditor extends JPanel { presentationWindow.setBackground(presentationBgColor); // windowActivated doesn't seem to do much, so focus listener better - presentationWindow.addFocusListener(new FocusAdapter() { + /*presentationWindow.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { //System.out.println("presentationWindow focusGained: " + e); try { @@ -244,7 +244,7 @@ public class PdeEditor extends JPanel { pdeRuntime.window.toFront(); } catch (Exception ex) { } } - }); + }); */ textarea.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { @@ -252,6 +252,7 @@ public class PdeEditor extends JPanel { if (presenting == true) { try { presentationWindow.toFront(); + pdeRuntime.applet.requestFocus(); } catch (Exception ex) { } } } @@ -264,6 +265,7 @@ public class PdeEditor extends JPanel { try { //System.out.println("moving presentation window to front"); presentationWindow.toFront(); + pdeRuntime.applet.requestFocus(); } catch (Exception ex) { } } } @@ -271,7 +273,10 @@ public class PdeEditor extends JPanel { // if user clicks on background presentationWindow, restore applet window // ("engine.window") to the front immediately - presentationWindow.addMouseListener(new MouseAdapter() { + + // toxi_030903: temporarily removed, don't seem to need those anymore + + /*presentationWindow.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { //System.out.println("mouseClicked: " + e.toString()); try { @@ -293,6 +298,20 @@ public class PdeEditor extends JPanel { pdeRuntime.window.toFront(); } catch (Exception ex) { } } + }); */ + + // toxi_030903: moved this from the PDERuntime window to our main presentation window + presentationWindow.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + //System.out.println("window got " + e); + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + pdeRuntime.stop(); + doClose(); + } else { + // toxi_030903: pass on the event to the applet + pdeRuntime.applet.keyPressed(e); + } + } }); } @@ -891,6 +910,9 @@ public class PdeEditor extends JPanel { //if (buildPath != null) { cleanTempFiles(); //buildPath); //} + + // toxi_030903: focus the PDE again after quitting presentation mode + base.toFront(); } diff --git a/processing/app/PdeRuntime.java b/processing/app/PdeRuntime.java index d743ec4c2..aacc50edd 100644 --- a/processing/app/PdeRuntime.java +++ b/processing/app/PdeRuntime.java @@ -96,18 +96,10 @@ public class PdeRuntime implements PdeMessageConsumer { applet.start(); if (editor.presenting) { - window = new Window(new Frame()); - window.addKeyListener(new KeyAdapter() { - public void keyPressed(KeyEvent e) { - //System.out.println("window got " + e); - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - //editor.doClose(); - //new DelayedClose(editor); - stop(); - editor.doClose(); - } - } - }); + //window = new Window(new Frame()); + // toxi_030903: attach applet window to editor's presentation window + window = new Window(editor.presentationWindow); + // toxi_030903: moved keyListener to PdeEditor's presentationWindow } else { window = new Frame(editor.sketchName); // gonna use ugly windows instead @@ -121,10 +113,9 @@ public class PdeRuntime implements PdeMessageConsumer { editor.doClose(); } }); - } - if (!(window instanceof Frame)) y1 += parentInsets.top; - window.add(applet); - + + // toxi_030903: only attach keyListener if not in presentation mode + // else events are coming directly from editor.presentationWindow applet.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { //System.out.println("applet got " + e); @@ -137,6 +128,13 @@ public class PdeRuntime implements PdeMessageConsumer { } }); + y1 += parentInsets.top; + } + // toxi_030903: moved this in the above else branch + // if (!(window instanceof Frame)) y1 += parentInsets.top; + + window.add(applet); + // @#$((* java 1.3 // removed because didn't seem to be needed anymore // also, was causing offset troubles