diff options
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 64 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java | 6 |
2 files changed, 21 insertions, 49 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 55f5f0533..86faea35f 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -272,10 +272,15 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("NewtCanvasAWT.FocusProperty: "+evt.getPropertyName()+", src "+evt.getSource()+", "+oldF+" -> "+newF+", isParent "+isParent+", isFS "+isFullscreen); } if(isParent && !isFullscreen) { - if(oldF == NewtCanvasAWT.this && newF == null) { + if(newF == NewtCanvasAWT.this) { + if(DEBUG) { + System.err.println("NewtCanvasAWT.FocusProperty: AWT focus -> NEWT focus traversal"); + } + requestFocusNEWTChild(); + } else if(oldF == NewtCanvasAWT.this && newF == null) { // focus traversal to NEWT - NOP if(DEBUG) { - System.err.println("NewtCanvasAWT.FocusProperty: NEWT focus traversal"); + System.err.println("NewtCanvasAWT.FocusProperty: NEWT focus"); } } else if(null != newF && newF != NewtCanvasAWT.this) { // focus traversal to another AWT component @@ -292,6 +297,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final FocusPropertyChangeListener focusPropertyChangeListener = new FocusPropertyChangeListener(); private volatile KeyboardFocusManager keyboardFocusManager = null; + private final void requestFocusNEWTChild() { + if(null!=newtChild) { + newtChild.setFocusAction(null); + if(isOnscreen) { + KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); + } + newtChild.requestFocus(); + newtChild.setFocusAction(focusAction); + } + } + /** * Sets a new NEWT child, provoking reparenting. * <p> @@ -602,50 +618,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } - private final void requestFocusNEWTChild() { - if(null!=newtChild) { - newtChild.setFocusAction(null); - if(isOnscreen) { - KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); - } - newtChild.requestFocus(); - newtChild.setFocusAction(focusAction); - } - } - - @Override - public void requestFocus() { - super.requestFocus(); - requestFocusNEWTChild(); - } - - @Override - public boolean requestFocus(boolean temporary) { - final boolean res = super.requestFocus(temporary); - if(res) { - requestFocusNEWTChild(); - } - return res; - } - - @Override - public boolean requestFocusInWindow() { - final boolean res = super.requestFocusInWindow(); - if(res) { - requestFocusNEWTChild(); - } - return res; - } - - @Override - public boolean requestFocusInWindow(boolean temporary) { - final boolean res = super.requestFocusInWindow(temporary); - if(res) { - requestFocusNEWTChild(); - } - return res; - } - private final boolean validateComponent(boolean attachNewtChild) { if( Beans.isDesignTime() || !isDisplayable() ) { return false; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java index 693dd1448..ff540408a 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java @@ -249,7 +249,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase { Assert.assertEquals(true, glWindow1FA.focusLost()); Thread.sleep(durationPerTest/numFocus); - // direct AWT request focus + System.err.println("Test: Direct NewtCanvasAWT focus"); try { java.awt.EventQueue.invokeAndWait(new Runnable() { public void run() { @@ -262,7 +262,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase { Assert.assertEquals(true, bWestFA.focusLost()); Thread.sleep(durationPerTest/numFocus); - // direct AWT request focus + System.err.println("Test: Direct AWT Button-West focus"); try { java.awt.EventQueue.invokeAndWait(new Runnable() { public void run() { @@ -275,7 +275,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase { Assert.assertEquals(true, glWindow1FA.focusLost()); Thread.sleep(durationPerTest/numFocus); - // direct NEWT request focus + System.err.println("Test: Direct NEWT-Child request focus"); glWindow1.requestFocus(); Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); Assert.assertEquals(true, glWindow1FA.focusGained()); |