[ 2656716 ] Focus management enhancement

- Fixed scrolling bug in previous commit
- Minor improvement in setfocus
This commit is contained in:
Heng Sin Low 2009-03-03 22:36:49 +00:00
parent 8c8399bac3
commit c5b01e5672
3 changed files with 17 additions and 13 deletions

View File

@ -18,7 +18,6 @@
package org.adempiere.webui.component;
import org.zkoss.zk.ui.Component;
import org.zkoss.zul.RowRenderer;
/**
*
@ -52,14 +51,4 @@ public class Grid extends org.zkoss.zul.Grid
}
return b;
}
/**
* Don't call this directly, only use by GridTabRowRenderer to send post render event
*/
public void onPostGridRender() {
RowRenderer renderer = this.getRowRenderer();
if (renderer instanceof GridTabRowRenderer) {
((GridTabRowRenderer)renderer).setFocusToField();
}
}
}

View File

@ -178,6 +178,7 @@ public class GridPanel extends Borderlayout implements EventListener
//this is needed to make focus and auto scroll work
org.zkoss.zul.Row row = (org.zkoss.zul.Row)listbox.getRows().getChildren().get(pgIndex);
listbox.renderRow(row);
Events.echoEvent("onPostRenderSelectedRow", this, null);
}
} else {
renderer.stopEditing(false);
@ -186,9 +187,17 @@ public class GridPanel extends Borderlayout implements EventListener
//this is needed to make focus and auto scroll work
org.zkoss.zul.Row row = (org.zkoss.zul.Row)listbox.getRows().getChildren().get(rowIndex);
listbox.renderRow(row);
Events.echoEvent("onPostRenderSelectedRow", this, null);
}
}
}
/**
* Don't call this directly, use internally to send post render event
*/
public void onPostRenderSelectedRow() {
renderer.setFocusToField();
}
/**
* set paging size

View File

@ -391,8 +391,6 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
*/
public void doFinally() {
lookupCache = null;
if (grid != null)
Events.echoEvent("onPostGridRender", grid, null);
}
/**
@ -407,6 +405,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
*/
public void setFocusToField() {
WEditor toFocus = null;
Label firstLabel = null;
for (WEditor editor : getEditors()) {
if (editor.isHasFocus()) {
toFocus = editor;
@ -418,9 +417,16 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
toFocus = editor;
}
}
if (firstLabel == null) {
if (editor.getComponent() instanceof Label) {
firstLabel = (Label) editor.getComponent();
}
}
}
if (toFocus != null)
Clients.response(new AuFocus(toFocus.getComponent()));
else if (firstLabel != null)
Clients.response(new AuFocus(firstLabel));
}
/**