App crashes on LG GT540

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.

[lua]-- 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 )[/lua] [import]uid: 44975 topic_id: 7971 reply_id: 307971[/import]

Does it do it in the simulator as well? [import]uid: 22824 topic_id: 7971 reply_id: 28363[/import]

In simulator

[lua]native.newTextField()[/lua]

doesn’t work. that is the problem :slight_smile: [import]uid: 44975 topic_id: 7971 reply_id: 28364[/import]

I’m seeing the same crashing problem in the Android SDK simulator. I’ll file a bug and investigate possible work-arounds. thanks.

Tim [import]uid: 8196 topic_id: 7971 reply_id: 28463[/import]

thanks.

and then i have such a question for workaround. Is there any way to make native UI text input field invisible ? [import]uid: 44975 topic_id: 7971 reply_id: 28477[/import]