diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java index 586f0dca60..27701017fb 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/NumberBox.java @@ -249,29 +249,27 @@ public class NumberBox extends Div txtCalc.setId(txtCalc.getUuid()); boolean processDotKeypad = MSysConfig.getBooleanValue(MSysConfig.ZK_DECIMALBOX_PROCESS_DOTKEYPAD, true, Env.getAD_Client_ID(Env.getCtx())); - if (".".equals(separator)) - processDotKeypad = false; - - // restrict allowed characters - String decimalSep = separator; - if (!processDotKeypad && !".".equals(separator)) - decimalSep += "."; StringBuffer funct = new StringBuffer(); funct.append("function(evt)"); funct.append("{"); - funct.append(" if (!this._shallIgnore(evt, '= -/()*%+0123456789").append(decimalSep).append("'))"); + if (processDotKeypad) { + funct.append(" if (!this._shallIgnore(evt, '= -/()*%+0123456789'))"); + } else { + // restrict allowed characters + String decimalSep = separator; + if (!processDotKeypad && !".".equals(separator)) + decimalSep += "."; + funct.append(" if (!this._shallIgnore(evt, '= -/()*%+0123456789").append(decimalSep).append("'))"); + } funct.append(" {"); funct.append(" this.$doKeyPress_(evt);"); funct.append(" }"); funct.append("}"); txtCalc.setWidgetOverride("doKeyPress_", funct.toString()); - txtCalc.setWidgetListener("onKeyUp", "calc.validateUp('" + + txtCalc.setWidgetListener("onKeyDown", "calc.validateDown('" + decimalBox.getId() + "','" + txtCalc.getId() + "'," + integral + "," + (int)separatorChar + ", event, " + ( processDotKeypad ? "true" : "false" ) + ");"); - txtCalc.setWidgetListener("onKeyPress", "calc.validatePress('" + - decimalBox.getId() + "','" + txtCalc.getId() - + "'," + integral + "," + (int)separatorChar + ", event);"); txtCalc.setMaxlength(250); txtCalc.setCols(30); diff --git a/org.adempiere.ui.zk/js/calc.js b/org.adempiere.ui.zk/js/calc.js index 40e0904160..2a502fa327 100644 --- a/org.adempiere.ui.zk/js/calc.js +++ b/org.adempiere.ui.zk/js/calc.js @@ -1,41 +1,25 @@ function Calc() { - this.validateUp = validateUp; - this.validatePress = validatePress; + this.validateDown = validateDown; this.clear = clear; this.clearAll = clearAll; this.evaluate = evaluate; this.append = append; - function validatePress(displayTextId, calcTextId, integral, separatorKey, e) - { - var key; - - if(window.event) - key = e.keyCode; //IE - else - key = e.which; //Firefox - // console.log("validatePress: " + displayTextId + " / " + calcTextId + " / " + integral + " / " + separatorKey + " / " + key); - if (key == 61) // = - { - evaluate(displayTextId, calcTextId, String.fromCharCode(separatorKey)); - } - } - - function validateUp(displayTextId, calcTextId, integral, separatorKey, e, processDotKeypad) + function validateDown(displayTextId, calcTextId, integral, separatorKey, e, processDotKeypad) { var key; if(window.event) key = e.keyCode; //IE else key = e.which; //Firefox - // console.log("validateUp: " + displayTextId + " / " + calcTextId + " / " + integral + " / " + separatorKey + " / " + key + " / " + processDotKeypad); - if (key == 13) // Enter + // console.log("validateDown: " + displayTextId + " / " + calcTextId + " / " + integral + " / " + separatorKey + " / " + key + " / " + processDotKeypad); + if (key == 13 || key == 61) // Enter { evaluate(displayTextId, calcTextId, String.fromCharCode(separatorKey)); } - else if (processDotKeypad && separatorKey != 46 && (key == 110 || key == 190) && !window.opera) // numeric dot on keypad (not working for opera) + else if (processDotKeypad && (key == 108 || key == 110 || key == 188 || key == 190 || key == 194)) { append(calcTextId, String.fromCharCode(separatorKey)); e.stop;