Cursor goes back to the beginning when string.sub is called in native text field on android device.

Every time the text has react the character limit i set, cursor goes back to the beginning of the textfield, where it should only delete the last character. This only happens on an android device. Why is this happening? Here are some of my codes:

if ( "editing" == event.phase) then if (string.len(newMoveName.text) \> 18) then newMoveName.text = string.sub(newMoveName.text,1,16); end [import]uid: 189861 topic_id: 35218 reply_id: 335218[/import]

This is an annoyance of how textfields work on Android OS, not so much a bug with Corona.

I researched this some time ago and it looked like it could be worked around with one line of native java code. Since it’s now a real bug, it does not seem to be a high priority for Corona Labs.

I personally think it is an important issue. I find if you want to use high score names, you will most likely want to limit the maximum number and type of characters allowed.

This is one of the issues preventing me from releasing to Android at the moment. [import]uid: 56820 topic_id: 35218 reply_id: 140409[/import]

Yeah, the cursor getting reset back to the start of the text field is the default Android behavior.

But you know what, its near the end of the day for me and I have time to sneak in a few minor code changes. I’ll modify the code to preserve the cursor’s position when the text gets updated. Just a moment please… [import]uid: 32256 topic_id: 35218 reply_id: 140416[/import]

Done! TextFields and TextBoxes will now preserve their cursor position(s) on Android when you update their text via Lua. This code change will be made available in daily build #1016, tomorrow. [import]uid: 32256 topic_id: 35218 reply_id: 140423[/import]

Sweeeet… little things like that can make a person’s day.

Thanks Joshua! [import]uid: 56820 topic_id: 35218 reply_id: 140424[/import]

Happy to help! And thank you for your patience.

It sounds like what you really need is a feature that sets the max character limit of a text field. I know this can be easily done on Android, but is a bit of work on iOS and Mac because Apple doesn’t provide this feature. In any case, this feature request is on our to-do list so that it won’t be forgotten. [import]uid: 32256 topic_id: 35218 reply_id: 140427[/import]

This is an annoyance of how textfields work on Android OS, not so much a bug with Corona.

I researched this some time ago and it looked like it could be worked around with one line of native java code. Since it’s now a real bug, it does not seem to be a high priority for Corona Labs.

I personally think it is an important issue. I find if you want to use high score names, you will most likely want to limit the maximum number and type of characters allowed.

This is one of the issues preventing me from releasing to Android at the moment. [import]uid: 56820 topic_id: 35218 reply_id: 140409[/import]

Yeah, the cursor getting reset back to the start of the text field is the default Android behavior.

But you know what, its near the end of the day for me and I have time to sneak in a few minor code changes. I’ll modify the code to preserve the cursor’s position when the text gets updated. Just a moment please… [import]uid: 32256 topic_id: 35218 reply_id: 140416[/import]

Done! TextFields and TextBoxes will now preserve their cursor position(s) on Android when you update their text via Lua. This code change will be made available in daily build #1016, tomorrow. [import]uid: 32256 topic_id: 35218 reply_id: 140423[/import]

Sweeeet… little things like that can make a person’s day.

Thanks Joshua! [import]uid: 56820 topic_id: 35218 reply_id: 140424[/import]

Happy to help! And thank you for your patience.

It sounds like what you really need is a feature that sets the max character limit of a text field. I know this can be easily done on Android, but is a bit of work on iOS and Mac because Apple doesn’t provide this feature. In any case, this feature request is on our to-do list so that it won’t be forgotten. [import]uid: 32256 topic_id: 35218 reply_id: 140427[/import]