Problem is: I see “Test” only when I click on the textfield. It sort of swipes in from the right side. I want it to be there from the beginning on though. It works fine on simulator, but not an Honor 8 or Galaxy S5 mini.
Any ideas?
// edit: Wow, narrowed it down to the line
usernameInput.align=“center”
If I leave it out, the username shows right away when the scene appears (positioned on the left side, as expected). But when I insert this line, the username only appears when I click on the textfield (positioned centered).
To me this does not make sense at all. Did I miss something? Why would aligning input text have such an impact on when the text appears on screen?
On my two android devices, the username is shown left-aligned and then, once timer kicks in, it disappears and only reappears when user clicks on the textfield.
Sorry for the answer Christopher. It’s really hard to discuss specifics without a lot of details and trying to understand your goals. Right now my capacity to try and investigate these is somewhat limited given I only have one Android tablet and I don’t have a project to look at and see what’s happening.
So I’m left with some generalities and sometimes I’m left to draw conclusions from that.
I could suggest that you look at our native.newTextField() sample app in Corona/SampleCode/Interface/NativeKeyboard and see how that behaves.
Rob, didnt mean to offend you in any way, sorry if there was a misunderstanding. I was just hoping that I did something wrong and could achieve my center-alignment by changing a simple line or something
I just created a new project and this is my main.lua
----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- -- Your code here local defaultField local function textListener( event ) if ( event.phase == "began" ) then -- User begins editing "defaultField" elseif ( event.phase == "ended" or event.phase == "submitted" ) then -- Output resulting text from "defaultField" print( event.target.text ) elseif ( event.phase == "editing" ) then print( event.newCharacters ) print( event.oldText ) print( event.startPosition ) print( event.text ) end end -- Create text field defaultField = native.newTextField( 150, 150, 180, 30 ) defaultField:addEventListener( "userInput", textListener ) defaultField.align = "center" defaultField.text = "blub"
Same result: In the simulator this works perfectly. As soon as the app gets launched, I see the “blub” centered. But when I launch it on my android devices, I get an empty text field. Only when I click on it, the “blub” appears.
If I leave out the
defaultField.align = "center"
“blub” is shown instantly, left-aligned, and no tap on the field is necessary. Hope it gets clearer now.
To me, this seems like a bug. But I understand all those difficulties you guys from Corona have with native, so I try to find a workaround…
/edit: Tested on Honor 8, Galaxy S5 mini and Samsung Tab S8. They all show a blank textfield when the app gets started. “Blub” only apears when user taps on textfield.
I ran it on my Google Nexus 9 (Android 7) and it works like you expect it would. “Username” was in the field when it started and stayed there as I tapped on the field.
I’ll see if I can get some additional testing on this.
We had someone else test on a couple of Android devices, but both are running more modern OS’s and it’s working as expected. At that point, perhaps you should go ahead and file a bug report.
Thank you for your efforts Rob. Hm, interesting. As I said, on all my three Android devices (even on my Honor 8) the “username” only shows up when I tap on the textfield.
Might I ask you to upload the .apk file that you put on your devices? I’d like to try exactly the same version that you install.
In the meantime I’ll read on how to file a bug report…
Ok, now I’m completely confused. Your version works perfectly.
So, to crosscheck afterwards, I recompiled my version and send it to my phone. Doesnt work, “username” does not appear.
How can this happen? As far as I know, the actual compilation happens on your servers. Why would the server compile my code different from yours (which is exactly the same as mine)?
On my two android devices, the username is shown left-aligned and then, once timer kicks in, it disappears and only reappears when user clicks on the textfield.
Sorry for the answer Christopher. It’s really hard to discuss specifics without a lot of details and trying to understand your goals. Right now my capacity to try and investigate these is somewhat limited given I only have one Android tablet and I don’t have a project to look at and see what’s happening.
So I’m left with some generalities and sometimes I’m left to draw conclusions from that.
I could suggest that you look at our native.newTextField() sample app in Corona/SampleCode/Interface/NativeKeyboard and see how that behaves.
Rob, didnt mean to offend you in any way, sorry if there was a misunderstanding. I was just hoping that I did something wrong and could achieve my center-alignment by changing a simple line or something
I just created a new project and this is my main.lua
----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- -- Your code here local defaultField local function textListener( event ) if ( event.phase == "began" ) then -- User begins editing "defaultField" elseif ( event.phase == "ended" or event.phase == "submitted" ) then -- Output resulting text from "defaultField" print( event.target.text ) elseif ( event.phase == "editing" ) then print( event.newCharacters ) print( event.oldText ) print( event.startPosition ) print( event.text ) end end -- Create text field defaultField = native.newTextField( 150, 150, 180, 30 ) defaultField:addEventListener( "userInput", textListener ) defaultField.align = "center" defaultField.text = "blub"
Same result: In the simulator this works perfectly. As soon as the app gets launched, I see the “blub” centered. But when I launch it on my android devices, I get an empty text field. Only when I click on it, the “blub” appears.
If I leave out the
defaultField.align = "center"
“blub” is shown instantly, left-aligned, and no tap on the field is necessary. Hope it gets clearer now.
To me, this seems like a bug. But I understand all those difficulties you guys from Corona have with native, so I try to find a workaround…
/edit: Tested on Honor 8, Galaxy S5 mini and Samsung Tab S8. They all show a blank textfield when the app gets started. “Blub” only apears when user taps on textfield.