Bug report (and patch): problem with focus handling

Maurizio De Cecco maurizio at mandrakesoft.com
Wed Apr 26 06:21:39 PDT 2000



The java.awt.Component.transferFocus and the default handler for the TAB key have a
different behaviour; in particular, the tansferFocus method do not
descend panels in the widget tree, as a consequence of the fact the
Panel.isFocusTraversable method return false.

The TAB shortcut handler do traverse panels, because it do not call the 
transferFocus method but it have its own implementation of traversal

A quick check with the Sun JDK show that the Sun transferFocus method
*does* traverse panels, so i suppose that is the correct behaviour;
the following patch implement this behaviour for the transferFocus method.

Ciao	 
	 Maurizio


-- snip -----------------------------------------------------------------------------
diff -ru kaffe-1.0.5.orig/libraries/javalib/java/awt/Component.java kaffe-1.0.5/libraries/javalib/java/awt/Component.java
--- kaffe-1.0.5.orig/libraries/javalib/java/awt/Component.java	Mon Oct 18 07:24:12 1999
+++ kaffe-1.0.5/libraries/javalib/java/awt/Component.java	Wed Apr 26 15:01:03 2000
@@ -1720,18 +1720,17 @@
 		/* Look for next focusable component after me */
 		for (start++; start < end; start++) {
 			Component c = parent.getComponent(start);
-			if (!(c.isEnabled() && ((c.flags & IS_VISIBLE) !=0) && c.isFocusTraversable())) {
-				continue;
-			}
-			if (!(c instanceof Container)) {
-				c.requestFocus();
-				return;
-			}
 
-			/* We found a new container, drop into it */
+			if (c.isEnabled() && ((c.flags & IS_VISIBLE) !=0) && c.isFocusTraversable()) {
+			  // Then if it is enabled, visible and focus traversable set the focus to it
+			  c.requestFocus();
+			  return;
+			} else if (c instanceof Container) {
+			  // If it is a container drop into it
 			parent = (Container)c;
 			end = parent.getComponentCount();
 			start = -1;
+			}
 		}
 
 		curr = parent;

-- snip -----------------------------------------------------------------------------
-- 
Maurizio De Cecco
MandrakeSoft 		http://www.mandrakesoft.com/


More information about the kaffe mailing list