Thanks!
This is what I have accomplished so far
field.addListener("input", function(e) {
var pos = field.getTextSelectionStart();
if (e.getOldData()!= null && e.getData().length >
e.getOldData().length) {
var value = field.getValue().replace(/-/g, "");
var newValue = "";
var cnt = 0;
for (var i = 0; i < value.length; i++) {
if (i % 4 == 3 && i > 0) {
newValue += value[i] + "-";
if (newValue.length == pos + 1)
cnt++;
}
else {
newValue += value[i];
}
}
field.setValue(newValue);
field.setTextSelection(pos + cnt, pos + cnt);
cnt = 0;
}
}, this);
It is not perfect:
- when a maxLength property is set, text field accepts one character and
this caracter messes up the 4-by-4 structure (dunno why, I think this
keypress event should not be propagated to the text field as long as its
maximum length is reached- is it a bug in the text field?)
- has some problems in Chrome when user moves the cursor and tries to add
something in the middle
Wojciech
--
View this message in context:
http://old.nabble.com/textField-masked-input-tp28447538p28458963.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.
------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel