Version 0.0.1
When focusing the field with an empty value and non-empty mask, starting with placeholder and containing some fixed characters, the cursor position is the first placeholder after the first fixed character sentence, not the first placeholder as expected.
E.g. we have a mask, say, like this: #-####
Initially empty field will look like this: _-____
When the control receives focus I expect the cursor to be in the first position:
_-____
^
expected cursor position
But it is actually here:
_-____
^
actual cursor position
Possible solution:
In VMaskedTextField.java in setMask() method there is a code:
...
setValue(string.toString());
updateCursor(0);
}
...
updateCursor(0) calls setCursorPos(getNextPos(pos))
getNextPos(0) will return 1 in our case, and the cursor will be set in the 1 (the second) instead of 0 (the first) position.
I think the problem may be fixed if we replace the updateCursor(0) call with setCursorPos(getPreviousPos(0)) as it in onFocus. It will implement the whole logic by finding the first non-fixed character (first placeholder) and position the cursor there.
Note, that the problem pops up only when we focus an empty-valued field (see onFocus event handler).
Version 0.0.1 When focusing the field with an empty value and non-empty mask, starting with placeholder and containing some fixed characters, the cursor position is the first placeholder after the first fixed character sentence, not the first placeholder as expected.
E.g. we have a mask, say, like this: #-#### Initially empty field will look like this: _-____ When the control receives focus I expect the cursor to be in the first position:
_-____ ^ expected cursor position
But it is actually here:
_-____ ^ actual cursor position
Possible solution: In VMaskedTextField.java in setMask() method there is a code: ... setValue(string.toString()); updateCursor(0); } ...
updateCursor(0) calls setCursorPos(getNextPos(pos)) getNextPos(0) will return 1 in our case, and the cursor will be set in the 1 (the second) instead of 0 (the first) position. I think the problem may be fixed if we replace the updateCursor(0) call with setCursorPos(getPreviousPos(0)) as it in onFocus. It will implement the whole logic by finding the first non-fixed character (first placeholder) and position the cursor there.
Note, that the problem pops up only when we focus an empty-valued field (see onFocus event handler).