IDEMPIERE-2003 Capturing wrong numbers with numeric keypad when decimal separator is not dot / similar problem in calculator
This commit is contained in:
parent
fbb5f74389
commit
abdf2d50d5
|
@ -249,29 +249,27 @@ public class NumberBox extends Div
|
||||||
txtCalc.setId(txtCalc.getUuid());
|
txtCalc.setId(txtCalc.getUuid());
|
||||||
|
|
||||||
boolean processDotKeypad = MSysConfig.getBooleanValue(MSysConfig.ZK_DECIMALBOX_PROCESS_DOTKEYPAD, true, Env.getAD_Client_ID(Env.getCtx()));
|
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();
|
StringBuffer funct = new StringBuffer();
|
||||||
funct.append("function(evt)");
|
funct.append("function(evt)");
|
||||||
funct.append("{");
|
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(" {");
|
||||||
funct.append(" this.$doKeyPress_(evt);");
|
funct.append(" this.$doKeyPress_(evt);");
|
||||||
funct.append(" }");
|
funct.append(" }");
|
||||||
funct.append("}");
|
funct.append("}");
|
||||||
txtCalc.setWidgetOverride("doKeyPress_", funct.toString());
|
txtCalc.setWidgetOverride("doKeyPress_", funct.toString());
|
||||||
|
|
||||||
txtCalc.setWidgetListener("onKeyUp", "calc.validateUp('" +
|
txtCalc.setWidgetListener("onKeyDown", "calc.validateDown('" +
|
||||||
decimalBox.getId() + "','" + txtCalc.getId()
|
decimalBox.getId() + "','" + txtCalc.getId()
|
||||||
+ "'," + integral + "," + (int)separatorChar + ", event, " + ( processDotKeypad ? "true" : "false" ) + ");");
|
+ "'," + integral + "," + (int)separatorChar + ", event, " + ( processDotKeypad ? "true" : "false" ) + ");");
|
||||||
txtCalc.setWidgetListener("onKeyPress", "calc.validatePress('" +
|
|
||||||
decimalBox.getId() + "','" + txtCalc.getId()
|
|
||||||
+ "'," + integral + "," + (int)separatorChar + ", event);");
|
|
||||||
txtCalc.setMaxlength(250);
|
txtCalc.setMaxlength(250);
|
||||||
txtCalc.setCols(30);
|
txtCalc.setCols(30);
|
||||||
|
|
||||||
|
|
|
@ -1,41 +1,25 @@
|
||||||
|
|
||||||
function Calc()
|
function Calc()
|
||||||
{
|
{
|
||||||
this.validateUp = validateUp;
|
this.validateDown = validateDown;
|
||||||
this.validatePress = validatePress;
|
|
||||||
this.clear = clear;
|
this.clear = clear;
|
||||||
this.clearAll = clearAll;
|
this.clearAll = clearAll;
|
||||||
this.evaluate = evaluate;
|
this.evaluate = evaluate;
|
||||||
this.append = append;
|
this.append = append;
|
||||||
|
|
||||||
function validatePress(displayTextId, calcTextId, integral, separatorKey, e)
|
function validateDown(displayTextId, calcTextId, integral, separatorKey, e, processDotKeypad)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
var key;
|
var key;
|
||||||
if(window.event)
|
if(window.event)
|
||||||
key = e.keyCode; //IE
|
key = e.keyCode; //IE
|
||||||
else
|
else
|
||||||
key = e.which; //Firefox
|
key = e.which; //Firefox
|
||||||
// console.log("validateUp: " + displayTextId + " / " + calcTextId + " / " + integral + " / " + separatorKey + " / " + key + " / " + processDotKeypad);
|
// console.log("validateDown: " + displayTextId + " / " + calcTextId + " / " + integral + " / " + separatorKey + " / " + key + " / " + processDotKeypad);
|
||||||
if (key == 13) // Enter
|
if (key == 13 || key == 61) // Enter
|
||||||
{
|
{
|
||||||
evaluate(displayTextId, calcTextId, String.fromCharCode(separatorKey));
|
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));
|
append(calcTextId, String.fromCharCode(separatorKey));
|
||||||
e.stop;
|
e.stop;
|
||||||
|
|
Loading…
Reference in New Issue