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());
|
||||
|
||||
boolean processDotKeypad = MSysConfig.getBooleanValue(MSysConfig.ZK_DECIMALBOX_PROCESS_DOTKEYPAD, true, Env.getAD_Client_ID(Env.getCtx()));
|
||||
if (".".equals(separator))
|
||||
processDotKeypad = false;
|
||||
|
||||
StringBuffer funct = new StringBuffer();
|
||||
funct.append("function(evt)");
|
||||
funct.append("{");
|
||||
if (processDotKeypad) {
|
||||
funct.append(" if (!this._shallIgnore(evt, '= -/()*%+0123456789'))");
|
||||
} else {
|
||||
// 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("'))");
|
||||
}
|
||||
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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue