I’ve been struggling for a week to get a textfield working. Rob, your solution works decently, except for the font scaling, but even then, it works better than my current one’s font scaling. It’s odd, because I copied yours, and it still doesn’t work the same for me.
I did notice that yours doesn’t work in a scrollviewer (because the x and y properties of the field don’t actually change when it’s scrolling up/down), so I had to do something like this:
local function syncFields(event) local xOffset, yOffset = background:localToContent(0,0) -- get absolute position of object offset, even within scrollview local newCenterX = background.x + xOffset local newCenterY = background.y + yOffset field.textField.x = newCenterX field.textField.y = newCenterY end
Maybe some of you guys know a better way to do that.
I’ll check out the widgetstown editfield too.
Just to add to the party, in my own custom solution, I set it up so that if i’m on Windows, it creates a simulated textfield, and lets me use my PC keyboard to enter text. It’s very, very rudimentary, and doesn’t allow selecting text, copying/pasting, or any of that. It’s basically just to make it usable for testing on a Windows PC. It simply listens for keyboard events and regurgitates it back to the screen.
The two main problems I’m having right now:
-
Font scaling
-
Events aren’t firing properly on the device itself; when I’m in the corona simulator, I set up an invisible overlay behind the textfield, so that when you tap out of it, it swaps it back to the newText object instead. This works great in the simulator, and doesn’t work in the iOS simulator or Genymotion (Nexus 7, Android 4.2.2).
By the way, I see a lot of folks going, “Hey, can you try it on [x].” I understand it’s better to test on a real device, but the Android emulators are pretty good for initial testing. I always felt the Android emulators were too slow to be usable until Genymotion.
If I can ever get things ironed out in my version, I’ll stick it up on github somewhere, even though it’s kinda ugly, so maybe someone can learn *something* from it that could be applied to some of these others…
Thanks,
Dave