Hi, can someone build and check on some other model of android next piece of code.
The problem is that I have checked on 2 different devices LG GT540 and it crashes after the first text input. So I cannot understand whether it is bug of code or LG's bug.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | -- Current display text field being edited local currentField -- Group to contain input text field local fieldGroup = display.newGroup() -- Reference to input text field local inputtext -- Handler for text input function handleInput( event ) if event.phase == "submitted" or event.phase == "ended" then if event.phase == "submitted" then currentField.text = inputtext.text end fieldGroup:remove(inputtext) inputtext = nil native.setKeyboardFocus( nil ) currentField = nil end end -- Touch handler to start edit operation on target text field -- Edit field is positioned at the same x/y and with same height/width as text box being edited function onTouch( event ) if event.phase == "began" then currentField = event.target if inputtext == nil then inputtext = native.newTextField(event.target.x - event.target.contentWidth/2, event.target.y - event.target.contentHeight/2, event.target.contentWidth, 30, handleInput) fieldGroup:insert(inputtext) inputtext.text = event.target.text native.setKeyboardFocus(inputtext) else fieldGroup:remove(inputtext) native.setKeyboardFocus(nil) end end end -- "Editable" text boxes local displayText = display.newText("Touch me to edit...", 120, 120, native.systemFont, 24) displayText.index = 1 local displayText2 = display.newText("Touch me...", 120, 160, native.systemFont, 24) displayText2.index = 2 local displayText3 = display.newText("Touch me three...", 120, 200, native.systemFont, 24) displayText3.index = 3 -- Touch listeners displayText:addEventListener("touch",onTouch ) displayText2:addEventListener("touch",onTouch ) displayText3:addEventListener("touch",onTouch ) |
Does it do it in the simulator as well?
In simulator
native.newTextField()
doesn't work. that is the problem :)
I'm seeing the same crashing problem in the Android SDK simulator. I'll file a bug and investigate possible work-arounds. thanks.
Tim
thanks.
and then i have such a question for workaround. Is there any way to make native UI text input field invisible ?