summaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-10-09 05:29:08 +0200
committerSven Gothel <[email protected]>2013-10-09 05:29:08 +0200
commit9997ce1f19accc2ef6b8568b5e3ba877710bef01 (patch)
tree9c4ca13d4217d61e5f9e8ab32865982ba3f9777e /src/newt
parent8be1fc983e584082b9960b4da19c56af5834d08e (diff)
NewtCanvasAWT Focus Traversal: Remove AWT's requestFocus*() overrides in favor of FocusPropertyChangeListener requestFocusNEWTChild()
The AWT's requestFocus*() overrides were intended to receive the AWT focus (default) and clear it afterwards to forward the focus to the NEWT component -> requestFocusNEWTChild(). This can be achieved simply by using our FocusPropertyChangeListener and invoking requestFocusNEWTChild() when receiving the focus on the NewtCanvasAWT component.
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java64
1 files changed, 18 insertions, 46 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;