IDEMPIERE-4468 Pass the current value of numberbox to the textfield of calculator (#430)
IDEMPIERE-2003 Capturing wrong numbers with numeric keypad when decimal separator is not dot
- Restore and improve functionality that process dot keypad within the number fields (deleted by mistake in c954a055b2
)
This commit is contained in:
parent
8b672a3a51
commit
a833e778a6
|
@ -91,6 +91,39 @@ public class NumberBox extends Div
|
|||
decimalBox.setSclass("editor-input");
|
||||
decimalBox.setId(decimalBox.getUuid());
|
||||
|
||||
char separatorChar = DisplayType.getNumberFormat(DisplayType.Number, null).getDecimalFormatSymbols().getDecimalSeparator();
|
||||
String separator = Character.toString(separatorChar);
|
||||
boolean processDotKeypad = MSysConfig.getBooleanValue(MSysConfig.ZK_DECIMALBOX_PROCESS_DOTKEYPAD, true, Env.getAD_Client_ID(Env.getCtx()));
|
||||
if (processDotKeypad && ! ".".equals(separator)) {
|
||||
/* this code works for the decimalbox - the calculator is managed in calc.js */
|
||||
StringBuffer funct = new StringBuffer();
|
||||
funct.append("function(evt)");
|
||||
funct.append("{");
|
||||
// ignore dot, comma and decimal separator and process them on key down
|
||||
funct.append(" if (!this._shallIgnore(evt, '0123456789-%'))");
|
||||
funct.append(" {");
|
||||
funct.append(" this.$doKeyPress_(evt);");
|
||||
funct.append(" }");
|
||||
funct.append("}");
|
||||
decimalBox.setWidgetOverride("doKeyPress_", funct.toString());
|
||||
funct = new StringBuffer();
|
||||
// debug // funct.append("console.log('keyCode='+event.keyCode);");
|
||||
funct.append("if (window.event)");
|
||||
funct.append(" key = event.keyCode;");
|
||||
funct.append("else");
|
||||
funct.append(" key = event.which;");
|
||||
funct.append("if (key == 108 || key == 110 || key == 188 || key == 190 || key == 194) {");
|
||||
funct.append(" var id = '$'.concat('").append(decimalBox.getId()).append("');");
|
||||
funct.append(" var calcText = jq(id)[0];");
|
||||
funct.append(" var position = calcText.selectionStart;");
|
||||
funct.append(" var newValue = calcText.value.substring(0, position) + '").append(separator).append("' + calcText.value.substring(position);");
|
||||
funct.append(" calcText.value = newValue;");
|
||||
funct.append(" calcText.setSelectionRange(position+1, position+1);");
|
||||
funct.append(" event.stop;");
|
||||
funct.append("};");
|
||||
decimalBox.setWidgetListener("onKeyDown", funct.toString());
|
||||
}
|
||||
|
||||
appendChild(decimalBox);
|
||||
|
||||
btn = new Button();
|
||||
|
|
Loading…
Reference in New Issue