Question about TextBox

Hi, I need to use the textbox control on a screen. I noticed there is an event for this control also. Do I need to use the event? Or can I just retrieve the text in another event? If so, how would I do that? If the control was called Text1 can I get the text from Text1.text?

Thanks,

Warren
[import]uid: 184193 topic_id: 33843 reply_id: 333843[/import]

You would indeed just go Text1.text to get the string from the textbox. You could probably of tested that quicker then asking :slight_smile:

The event listener is not necessary. [import]uid: 147305 topic_id: 33843 reply_id: 134525[/import]

You would indeed just go Text1.text to get the string from the textbox. You could probably of tested that quicker then asking :slight_smile:

The event listener is not necessary. [import]uid: 147305 topic_id: 33843 reply_id: 134525[/import]

I used a textfield control and when I tried to use the text property of it my app didn’t continue running. U referred to it as field1.text. If I replaced it with “Hello world!” it works fine. Is there anything special I need to do to refer to the control and get the text entered?

Thanks
[import]uid: 184193 topic_id: 33843 reply_id: 134843[/import]

Not really. If you declared the text object as a local variable inside of a function then you wouldn’t be able to reference that object outside of that function, even though it’s still on the screen.

Below is a simple example of it working.

[lua] local textBox = native.newTextBox( 15, 70, 280, 70 )
textBox.text = “This is my text”
print(textBox.text)[/lua]
Might want to post some of your code if you are still having issues. [import]uid: 147305 topic_id: 33843 reply_id: 134851[/import]

You nailed it! I declared it inside of a function and then tried to refer to it in another function. I’ll change it to declare at the beginning and go from there.

Thanks!

Warren
[import]uid: 184193 topic_id: 33843 reply_id: 134855[/import]

I used a textfield control and when I tried to use the text property of it my app didn’t continue running. U referred to it as field1.text. If I replaced it with “Hello world!” it works fine. Is there anything special I need to do to refer to the control and get the text entered?

Thanks
[import]uid: 184193 topic_id: 33843 reply_id: 134843[/import]

Not really. If you declared the text object as a local variable inside of a function then you wouldn’t be able to reference that object outside of that function, even though it’s still on the screen.

Below is a simple example of it working.

[lua] local textBox = native.newTextBox( 15, 70, 280, 70 )
textBox.text = “This is my text”
print(textBox.text)[/lua]
Might want to post some of your code if you are still having issues. [import]uid: 147305 topic_id: 33843 reply_id: 134851[/import]

You nailed it! I declared it inside of a function and then tried to refer to it in another function. I’ll change it to declare at the beginning and go from there.

Thanks!

Warren
[import]uid: 184193 topic_id: 33843 reply_id: 134855[/import]