[ 2656716 ] Focus management enhancement
- Fixed scrolling bug in previous commit - Minor improvement in setfocus
This commit is contained in:
parent
8c8399bac3
commit
c5b01e5672
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue