backout f018794 - IDEMPIERE-611 Zk: number editor popup auto close immediately. - seems like in newer versions of zk the previous patch was correct to get the focus on calculator and latest patch didn't get focus

This commit is contained in:
Carlos Ruiz 2018-12-23 15:29:09 +01:00
parent e00b022e12
commit ec8c384c5f
1 changed files with 16 additions and 3 deletions

View File

@ -28,7 +28,9 @@ import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.MSysConfig;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.zkoss.zk.ui.HtmlBasedComponent;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Decimalbox;
@ -127,9 +129,20 @@ public class NumberBox extends Div
btn.setImage(ThemeManager.getThemeResource("images/Calculator16.png"));
btn.setTabindex(-1);
ZKUpdateUtil.setHflex(btn, "0");
btn.setWidgetListener("onClick", "try{var id=this.getPopup(); zk.Widget.$(id.substring(5, id.length - 1)).focus_(100);" +
"} catch(error) {}");
btn.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (btn.getPopup() != null) {
String uid = btn.getPopup();
if (uid.startsWith("uuid("))
uid = uid.substring(5, uid.length()-1);
HtmlBasedComponent comp = (HtmlBasedComponent) btn.getDesktop().getComponentByUuidIfAny(uid);
if (comp != null) {
comp.focus();
}
}
}
});
LayoutUtils.addSclass("editor-button", btn);
appendChild(btn);