Reputation: 742
When fires an textfield textChange and replace or add some content to the string binded the cursor goes to Start (in Android with NativeScript 5.0 Core). Here is the code:
page.getViewById("productPrizeTextField")
.addEventListener("textChange", function () {
if(mv.productPrize.includes('.')) {
mv.productPrize = mv.productPrize.replace(".", ",");
}
validation();
})
I found that it's an issue, but are there any method to cheat that cursor moving it to the end?
Upvotes: 1
Views: 423
Reputation: 21908
That's the default behavior of Android. The workaround is to call setSelection
method on native text view.
....
mv.productPrize = mv.productPrize.replace(".", ",");
if (args.object.android) {
// Where 'args' is argument passed to textChange event
args.object.android.setSelection(mv.productPrize.length);
}
...
Upvotes: 3