Moving text field position on keyboard show in Lua for Android -
I am using SDK "Corona" to develop an Android application in Leah.
I was thinking that all of you can experience me in the following problems which I have experienced. I am in the process of designing an app with a text field at the bottom of the screen, but I would like to change the position of touching the text field once, so that the keyboard does not overlap when it pops up.
In this way, I created a listener to execute the code, which changes the Y position of 2 field, either one is touched, but for some strange reason, code is not working Has been doing. If I put the code in a button event listener, then it works fine. Please see my code:
---------------- Email text box ------------- Local TextField = Native.newTextField (display.contentCenterX, display.contentCenterY + 60, 200, 40) textField.placeholder = "email" textField.isEditable = True --Function events to handle events in the local function touchListener (event) textField.y = display. ContentCenterY - 100 textField2.y = display.contentCenterY - 50th End textfield: addEventListener ("touch", touchListener)
I thank you in advance for your help
If I am right, because textFields are a native object (and not a display object), they do not handle the "touch" event like That you will need to use the "user input" event to trigger textField's move.
Here is an example of the fact that I have used this case in the past (to move the code without):
local function fctFieldListener (oEvent ) Local oTextField = oEvent.target if "start" == oEvent.phase Then - move the input down if oEvent.phase at the bottom "edit" == elseif "submit" == oEvent.phase then native.setKeyboardFocus (zero ) Elseif "expired" == oEvent.phase so - then move the input back to its original location, then adjust the end end
and you can use text fields like this Add to:
oTextField: addEventListener ('userInput', fctFieldListener)
In addition to this, I highly recommend that you enter a specific display group Native is inserted. NEEETEXFOLD, which you are moving around, makes things much easier instead of walking around the text.
Comments
Post a Comment