In iOS is impossible to retrieve the TextBox text why it always returns nil. Look my code:
myTextBox.text = “some text”
print("text: "…tostring(myTextBox.text))
This print nil, although the “some text” is displayed correctly in the screen.
Is there a know issue about it? I am using the simulator version 2013.1219.
Hi @andre50,
I believe that info (.text, etc.) is only returned to you from the associated listener function, as shown in the example at the bottom of this document:
http://docs.coronalabs.com/api/library/native/newTextBox.html
Please test that and see if it works.
Best regards,
Brent
That is correct, but that example is a little different. The event.text return nil, while the event.target.text works fine. Look:
[lua]
local keyboardEvent = function( event )
print(event.text, event.target.text)
return true
end
myTextBox.text = “text”
myTextBox:addEventListener( “userInput”, keyboardEvent )
[/lua]
When the text box receive focus, is printed “nil, text”
Hi @andre50,
I believe that info (.text, etc.) is only returned to you from the associated listener function, as shown in the example at the bottom of this document:
http://docs.coronalabs.com/api/library/native/newTextBox.html
Please test that and see if it works.
Best regards,
Brent
That is correct, but that example is a little different. The event.text return nil, while the event.target.text works fine. Look:
[lua]
local keyboardEvent = function( event )
print(event.text, event.target.text)
return true
end
myTextBox.text = “text”
myTextBox:addEventListener( “userInput”, keyboardEvent )
[/lua]
When the text box receive focus, is printed “nil, text”