From b9f7857f57bacf1b2c24dbdb00c1f2bb2821c84b Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sat, 16 May 2015 23:25:40 -0400 Subject: [PATCH] requestFocus() out of PSurface, key events firing in FX --- core/src/processing/core/PSurface.java | 6 +++--- core/src/processing/core/PSurfaceAWT.java | 2 +- core/src/processing/core/PSurfaceFX.java | 11 ++++++----- core/src/processing/core/PSurfaceNone.java | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/src/processing/core/PSurface.java b/core/src/processing/core/PSurface.java index f8d222d2f..0dfb382fe 100644 --- a/core/src/processing/core/PSurface.java +++ b/core/src/processing/core/PSurface.java @@ -108,9 +108,9 @@ public interface PSurface { public void setFrameRate(float fps); - // called on the first frame so that the now-visible drawing surface can - // receive key and mouse events - public void requestFocus(); +// // called on the first frame so that the now-visible drawing surface can +// // receive key and mouse events +// public void requestFocus(); // // finish rendering to the screen (called by PApplet) // public void blit(); diff --git a/core/src/processing/core/PSurfaceAWT.java b/core/src/processing/core/PSurfaceAWT.java index a00ba94f8..4abe5f515 100644 --- a/core/src/processing/core/PSurfaceAWT.java +++ b/core/src/processing/core/PSurfaceAWT.java @@ -111,7 +111,7 @@ public class PSurfaceAWT extends PSurfaceNone { * invokeLater() happens in here rather than requiring the caller to wrap it. */ @Override - public void requestFocus() { + void requestFocus() { // for 2.0a6, moving this request to the EDT EventQueue.invokeLater(new Runnable() { public void run() { diff --git a/core/src/processing/core/PSurfaceFX.java b/core/src/processing/core/PSurfaceFX.java index 35b8d60d9..36fda8ef8 100644 --- a/core/src/processing/core/PSurfaceFX.java +++ b/core/src/processing/core/PSurfaceFX.java @@ -115,6 +115,7 @@ public class PSurfaceFX implements PSurface { EventHandler keyHandler = new EventHandler() { public void handle(KeyEvent e) { + System.out.println(e); fxKeyEvent(e); } }; @@ -231,6 +232,7 @@ public class PSurfaceFX implements PSurface { Platform.runLater(new Runnable() { public void run() { stage.show(); + canvas.requestFocus(); } }); } @@ -408,11 +410,10 @@ public class PSurfaceFX implements PSurface { } - @Override - public void requestFocus() { - // TODO Auto-generated method stub - - } +// @Override +// public void requestFocus() { +// canvas.requestFocus(); +// } public void setCursor(int kind) { diff --git a/core/src/processing/core/PSurfaceNone.java b/core/src/processing/core/PSurfaceNone.java index 943f2b25d..79f206e9b 100644 --- a/core/src/processing/core/PSurfaceNone.java +++ b/core/src/processing/core/PSurfaceNone.java @@ -141,7 +141,7 @@ public class PSurfaceNone implements PSurface { } - public void requestFocus() { + void requestFocus() { // TODO Auto-generated method stub }