Is there a way to have multiple listeners from different textFields all refer to a single function when they enter the began phase? I’m thinking there should be a way to implement self but I don’t really know. I messed around with self:removeSelf() before but I’m this situation may be different. Thanks in advance! [import]uid: 35535 topic_id: 32869 reply_id: 332869[/import]
I believe you can add a listener to all the fields and just use event.target:removeSelf()
Eg;
[lua]local field1 = native.newTextField(10, 10, 100, 20)
local field2 = native.newTextField(10, 40, 100, 20)
local function enterText(event)
if event.phase == “began” then
event.target:removeSelf()
end
end
field1:addEventListener(“userInput”, enterText)
field2:addEventListener(“userInput”, enterText)[/lua]
Peach 
[import]uid: 52491 topic_id: 32869 reply_id: 130768[/import]
I believe you can add a listener to all the fields and just use event.target:removeSelf()
Eg;
[lua]local field1 = native.newTextField(10, 10, 100, 20)
local field2 = native.newTextField(10, 40, 100, 20)
local function enterText(event)
if event.phase == “began” then
event.target:removeSelf()
end
end
field1:addEventListener(“userInput”, enterText)
field2:addEventListener(“userInput”, enterText)[/lua]
Peach 
[import]uid: 52491 topic_id: 32869 reply_id: 130768[/import]
Okay thanks! I’ll try it out with the event.target. But will this work if I just need a single function to delete all my placeholder text when in the “began” phase? Should I make it event.target.text = “” in order to blank it out? [import]uid: 35535 topic_id: 32869 reply_id: 131343[/import]
I tried it out and it worked well. The only problem I see is when I click on the textField to begin editing (what I thought I read to be the “began” stage) nothing happens. I have to hit delete and then the text goes away. But if I hit any letter, the text will go away but then you can no longer edit the field. Weird. I made a comment about this before and someone said I should report a bug but I haven’t tested it on a device yet. [import]uid: 35535 topic_id: 32869 reply_id: 131345[/import]
I’ve got multiple text input areas on the same screen all using the same input “processing”/listener, however… I only have one native textfield created at a time (and it only exists during the input/until they tap done or another object ).
Essentially, I’ve put listeners on objects/rectangles where the text input happens, and when the rectangle is touched it immediately sets the keyboard focus to nil to end any other text input that was ongoing (and the previous native field is removed in that event/callback, and its result stored during the callback).
Following that, the new/current native field is created and receives events (passing in a callback function pointer, which will clean up the display and store the returned text result when input ends).
And again, when another object on the screen is touched, the first thing its handler does is set the keyboard focus to nil (ending any text edit process, which removes the native field and sets my standard text field to the native text result).
Switching fields is seamless. Although a call is made to set focus to nil, and then the callback occurs, the storing of the data, and redisplaying the non-native text field happens (all during the callback), the new native field is fired up and appears so quickly, the onscreen keyboard never flinches.
Just another way to deal with it (sorry coronaLabs, text input is more of an area to be “dealt with”, not rejoiced over).
If you do a lot of input, you might want to centralize it all through a system. The common handler (on init) takes params to manage a lot of aspects of the text, like size, number of chars, and other things the more basic corona functions don’t manage directly. Best of luck! [import]uid: 79933 topic_id: 32869 reply_id: 131352[/import]
Okay thanks! I’ll try it out with the event.target. But will this work if I just need a single function to delete all my placeholder text when in the “began” phase? Should I make it event.target.text = “” in order to blank it out? [import]uid: 35535 topic_id: 32869 reply_id: 131343[/import]
I tried it out and it worked well. The only problem I see is when I click on the textField to begin editing (what I thought I read to be the “began” stage) nothing happens. I have to hit delete and then the text goes away. But if I hit any letter, the text will go away but then you can no longer edit the field. Weird. I made a comment about this before and someone said I should report a bug but I haven’t tested it on a device yet. [import]uid: 35535 topic_id: 32869 reply_id: 131345[/import]
I’ve got multiple text input areas on the same screen all using the same input “processing”/listener, however… I only have one native textfield created at a time (and it only exists during the input/until they tap done or another object ).
Essentially, I’ve put listeners on objects/rectangles where the text input happens, and when the rectangle is touched it immediately sets the keyboard focus to nil to end any other text input that was ongoing (and the previous native field is removed in that event/callback, and its result stored during the callback).
Following that, the new/current native field is created and receives events (passing in a callback function pointer, which will clean up the display and store the returned text result when input ends).
And again, when another object on the screen is touched, the first thing its handler does is set the keyboard focus to nil (ending any text edit process, which removes the native field and sets my standard text field to the native text result).
Switching fields is seamless. Although a call is made to set focus to nil, and then the callback occurs, the storing of the data, and redisplaying the non-native text field happens (all during the callback), the new native field is fired up and appears so quickly, the onscreen keyboard never flinches.
Just another way to deal with it (sorry coronaLabs, text input is more of an area to be “dealt with”, not rejoiced over).
If you do a lot of input, you might want to centralize it all through a system. The common handler (on init) takes params to manage a lot of aspects of the text, like size, number of chars, and other things the more basic corona functions don’t manage directly. Best of luck! [import]uid: 79933 topic_id: 32869 reply_id: 131352[/import]