native.newTextField issue

I’ve been porting my iOS game to Android with Corona, and mostly it’s been smooth. It’s a simple anagram game that uses the keyboard.

The issue I am having is from using the native keyboard and native textfield. Currently I have a convoluted system with a native TextField that takes input from the native keyboard and another Corona text object that copies the TextField text but only allows letters in the anagram to appear. However, I still cannot get it to work quite right.

I think if I could do any of the following it would work:

  • native.setKeyboardFocus( textfield ) sets the cursor to the beginning of the line in the native TextField – if it set the cursor to the end of the line then my game would work, or if I could move the cursor from my code
  • if I could capture native keyboard keypresses directly (specifically, backspace) from my code
  • if I could delete one character from the end of the native TextField (mimic a backspace keypress) from my code

I am eager to release something on Corona but it’s pretty painful to get stuck like this. I’ve tried the XUI floating keyboard, but it looks odd since it’s a small ipad keyboard on the kindle fire (about half the height of the real keyboard), and it does not respond that well to keypresses compared to the native keyboard.

Thanks! [import]uid: 94304 topic_id: 25859 reply_id: 325859[/import]

You could delete one character from the end but I’m not sure how to advise further on that without knowing quite what the goal is with that question - but yes, deleting one character from the end of a string is possible - you’d get the length and then cut the string to be the length -1 char. (Can help with a little example code for that if needed.)

Peach :slight_smile: [import]uid: 52491 topic_id: 25859 reply_id: 104607[/import]

Hi Peach,

thanks for the response.

I guess I didn’t explain that one problem is that if you rearrange the tiles in the anagram, I want the textfield to update with the new arrangement of letters. Whenever I do this, the cursor moves to the start of the line.

If I set textfield.text to the string less one letter, then the act of changing textfield.text also moves the cursor to the beginning of the word. It’s different to what happens when you press backspace, so I can’t remove letters you type that are not in the anagram.

So here is an example:

Start with no text:
|
Type some letters into native.TextField:
abcfed|
Then I rearrange the anagram tiles and the TextField updates to match:
|abcdfe
Now I have to manually move the cursor to the end:
abcdfe|
Now I type the letter x, which is not in the anagram:
abcdefex|
I notice that it’s not in the anagram, so I delete it by changing textfield.text:
|abcdefe
Cursor goes back to the beginning of the line again.

I can get around some of this by using another text object that copies text from the native.TextField only when it’s a letter in the anagram, but specifically what goes wrong in this case is if I rearrange the tiles before typing any characters, then I can’t tell when backspace is pressed because the TextField doesn’t change when you press backspace until there are some characters typed in there.

I guess this means that another way to solve the problem is if the native TextField started off with MAX_LEN_ANAGRAM characters already in it, and the cursor at the end. This way I could detect backspace presses by checking the length of the TextField before any characters are typed.

[import]uid: 94304 topic_id: 25859 reply_id: 104651[/import]

I am having the same problem for my app. I requested a bug fix for this for two month ago, but haven’t head anything since then.

this bug makes the native.newtextfield unusable for android devices. [import]uid: 103182 topic_id: 25859 reply_id: 104694[/import]

I understand what you are saying with that clarification and can see why it is an issue - mareclo, do you have a bug number that I can try to bump, please? [import]uid: 52491 topic_id: 25859 reply_id: 104818[/import]

I think it is : #13284
I would really appreciate if you could tell them to put this on priority.
Thank you! [import]uid: 103182 topic_id: 25859 reply_id: 104859[/import]

Thanks Peach. Looking forward to launching my app, and seeing Marcelo’s:) [import]uid: 94304 topic_id: 25859 reply_id: 104920[/import]

Hey guys,

Just to update you;

Spoke to another member of the team about this and it’s actually been marked as a feature request and not a bug as the functionality to move/place the text cursor was never included/documented.

Hopefully we will have more news on it soon.

Peach :slight_smile: [import]uid: 52491 topic_id: 25859 reply_id: 105022[/import]

Hi!
To have an option of placing the text cursor, that is a feature. But when the text cursor automaticly is placed in the beginning of the text with no possibility of moving it, to me, that is a bug.

In my opinion this should be first priority since the textfield is kind of useless on android at the moment. Ansca, you really need to focus on the bugs rather than constantly adding new functionality. It is better to have a bug free Stable SDK with less features than the other way around. [import]uid: 103182 topic_id: 25859 reply_id: 105058[/import]

Yep, even if the marker/cursor just went to the end of the line on native.setKeyboardFocus, I could make it work…
[import]uid: 94304 topic_id: 25859 reply_id: 105064[/import]

My workaround to this problem was to create my own keyboard. =) You can see it here :

http://www.youtube.com/watch?v=KEqmIXmKoEY

Howevere, a lot of users would like to use their own keyboard ( swipe for example ), and that is not possible with the current bug.

[import]uid: 103182 topic_id: 25859 reply_id: 105067[/import]

Looks good, Marcelo.

If it looks like it’s going to take more than a month or so, I’ll probably make my own keyboard… [import]uid: 94304 topic_id: 25859 reply_id: 105164[/import]

That’s a very cool workaround, though I hope we can sort something out with this in the near future. (We hope to have a voting system for new features in place soon which would help with this.)

Peach :slight_smile: [import]uid: 52491 topic_id: 25859 reply_id: 105351[/import]

When you say “near future”, what does that mean approximately? Even though i have solved the problem with my own custom keyboard, many of the users of my app has requested the ability to use their own native keyboard, but i can’t give that to them. I have that function ready to be launched as soon as the bug is fixed.
I’m saying it again, i really think this is number one priority. It is a standard feature that should work. It should be fixed till the next release.

Sorry if i sound rude, that is not my point. I’m just pretty stressed about the fact that a very stupid bug is holder me ( and many others ) back from completing our apps.

[import]uid: 103182 topic_id: 25859 reply_id: 105354[/import]

So is it possible to push this to priority? More and more users are requesting this. On twitter as well.
Please, The main reason for people not voting a 5 star is mainly because of this function. Pleeeaaase fix this till the next daily build.

[import]uid: 103182 topic_id: 25859 reply_id: 105507[/import]

Hey again,

As I said I hope it is something we can sort something out in the near future; by that I mean exactly what I said, we’re working on a voting system so users can make their priorities clear and the team can try to make those requests happen.

In any case this definitely isn’t something that will happen in the next daily build, sorry :frowning: [import]uid: 52491 topic_id: 25859 reply_id: 105558[/import]

Hi Peach,
thanks for keeping us updated. Any timeline that emerges will help with planning.
Brian
[import]uid: 94304 topic_id: 25859 reply_id: 105964[/import]

Hi Peach!
I have experimentet around with the textfield , trying to get the cursor to appear at the end of the text.

It seems like the bug occures when there is a delay between the creating the text and settings the native keyboard. Everytime you use a delay before you use native.setKeyboardFocus, the cursor appears in the beginning of the text. The problem is that delays occures even without you using a timer because of many processes, animations etc…

So, i don’t know if this info will help you with fixing the bug, but it should give you some clue of what can be causing the problem.

* Cursor appears in the beginning of the text if there is a delay between creating the text and native.setKeyboardFocus

* Cursor appears in the beginning of the text, if you change the text after you have set native.setKeyboardFocus for the first time on that textField.

I really hope this can be fixed very soon. Thanks for your time.

/ Marcelo [import]uid: 103182 topic_id: 25859 reply_id: 106519[/import]

Hey Marcelo, if you reply to the email you got when you filed the bug you can include all this info and it will automatically be added to the bug report/feature request for whoever it is assigned to.

Peach :slight_smile: [import]uid: 52491 topic_id: 25859 reply_id: 106654[/import]

Hello,
any update on this?
Thanks! [import]uid: 94304 topic_id: 25859 reply_id: 109351[/import]