[Thinlet-development] Patch for thinlet
Brought to you by:
bajzat
From: Michael N. S. <mis...@ho...> - 2004-06-05 23:21:16
|
Hi folks, The following patch should solve the following problems: - While using a Thinlet application with a keyboard and doing dynamic removal/addition of components, such as rows, the app may halt when a key is pressed inside some components (eg. table, when all the rows are removed and some are added later); - Invoking an action using the keyboard does not focus the current component as expected If Robert or Andrzej are able to commit it, I'd be glad. It'd be better if you could fix the pending commit acccess issues, though. Regards, Michael Nascimento Santos JSR 207 Expert Group Member http://today.java.net/pub/au/80 Sun Certified Programmer for the Java 2 Platform Sun Certified Mobile Application Developer Sun Certified Web Component Developer for J2EE Moderador SouJava - http://www.soujava.org.br Index: Thinlet.java =================================================================== RCS file: /cvsroot/thinlet/thinlet/src/java/thinlet/Thinlet.java,v retrieving revision 1.9 diff -w -b -u -r1.9 Thinlet.java --- Thinlet.java 20 Apr 2004 11:10:29 -0000 1.9 +++ Thinlet.java 5 Jun 2004 22:08:44 -0000 @@ -2138,6 +2138,11 @@ } else { //if (("list" == classname) || ("table" == classname) || ("tree" == classname)) Object lead = get(component, ":lead"); + + if (getIndex(component, lead) == -1) { + set(component, ":lead", lead = null); + } + int[] columnwidths = ("table" == classname) ? ((int []) get(component, ":widths")) : null; boolean line = getBoolean(component, "line", true); int iline = line ? 1 : 0; boolean angle = ("tree" == classname) && getBoolean(component, "angle", false); @@ -3281,6 +3286,11 @@ (keycode == KeyEvent.VK_PAGE_DOWN) || (keycode == KeyEvent.VK_HOME) || (keycode == KeyEvent.VK_END)) { Object lead = get(component, ":lead"); + + if (getIndex(component, lead) == -1) { + set(component, ":lead", lead = null); + } + Object row = getListItem(component, component, keycode, lead, recursive); if (row != null) { String selection = getString(component, "selection", "single"); @@ -4206,6 +4216,8 @@ private boolean invoke(Object component, Object part, String event) { Object method = get(component, event); if (method != null) { + if (focusowner!=null && "action".equals(event)) + requestFocus(component); invokeImpl(method, part); return true; } @@ -4954,6 +4966,10 @@ * */ private int getIndex(Object component, Object value) { + if (value == null) { + return -1; + } + int index = 0; for (Object item = get(component, ":comp"); item != null; item = get(item, ":next")) { if (value == item) { return index; } |