
Originally Posted by
jonas.esser
Hello,
the checkVal() Method returns the wrong position. I added
a++;
before "return a;" to correct the position.
GXT Version: 2.2.0
Best Regards,
Jonas
For anyone stumbling across this - This solution will only work when the first editable character is in the second position. I have implemented a small fix that will handle the cases where the first editable character is in any position. Basically, the original code is always skipping over the a = i; because of the use of the break statements. I am using GXT Version 2.3.0
Code:
private int checkVal(boolean allow) {
String test = "";
if (getValue() != null) {
test = getValue();
}
int lastMatch = -1;
int a = 0;
for (int i = 0, pos = 0; i < len; i++) {
if (tests[i] != null) {
buffer[i] = settings.getPlaceHolder();
while (pos++ < test.length()) {
String c = String.valueOf(test.charAt(pos - 1));
if (c.matches(tests[i])) {
buffer[i] = String.valueOf(c);
lastMatch = i;
a = i;
break;
}
}
if (pos > test.length()) {
a = i;
break;
}
} else if (i != partialPosition) {
try {
char d = test.charAt(pos);
if (buffer[i].equals(String.valueOf(d))) {
pos++;
lastMatch = i;
}
} catch (Exception e) {
continue;
}
}
}
if (!allow && lastMatch + 1 < partialPosition) {
setValue("");
clearBuffer(0, len);
} else if (allow || lastMatch + 1 >= partialPosition) {
writeBuffer();
if (!allow) {
if (getValue() != null) {
setValue(getValue().substring(0, lastMatch + 1));
}
}
}
return a;
}