remove text in text field when user taps the textfield

I need to remove the text in a textfield when the user clicks the field. I´ve tried adding a listener but it didn´t work

[code]
local textBox = native.newTextField( 210, 200, 100, 30, txtList)
textBox:setTextColor(0, 0, 0, 255 )
textBox.hasBackground = false
textBox.inputType = “number”
textBox.text = “Price”

function txtBxLst ()
textBox.text = “”
end

textBox:addEventListener(“tap”, txtBxLst)
[/code] [import]uid: 93074 topic_id: 21358 reply_id: 321358[/import]

You could try

[lua]local textBox = native.newTextField( 210, 200, 100, 30, txtList)
textBox:setTextColor(0, 0, 0, 255 )
textBox.hasBackground = false
textBox.inputType = “number”
textBox.text = “Price”

function txtBxLst:touch( event )
if(event.phase == “began”) then
textBox.text = " "
elseif ( “ended” == event.phase ) then

end
end

textBox:addEventListener(“touch”, txtBxLst) [import]uid: 7845 topic_id: 21358 reply_id: 84547[/import]

thanks for your reply a3mg, but are you sure your code works? I try added it but it didn´t work [import]uid: 93074 topic_id: 21358 reply_id: 84549[/import]

This is a difficult situation because textFields are native display objects, not Corona display objects, so you can’t add listeners to them, and you can’t overlay objects on top of them either. Have you tried adding a Runtime event listener to listen to all “taps” and just check to see if the tap occured within the bounds of the textField? [import]uid: 52430 topic_id: 21358 reply_id: 84572[/import]

@aliennude: my bad, was trying to remember how we did it for our Valentine’s Hearts App. We used that code but it was for little X buttons next to the textFields and not for clicking on the actual textFields. So clicking the X cleared the text box next to it.

Valentine’s Hearts [import]uid: 7845 topic_id: 21358 reply_id: 84587[/import]