Sorry Matt,
It was code specific to another app I did, and there was extra code there to control the length the text and other user input, etc…
Here is a code sample (based on your example code) that works.
* be sure to use the 'if e.phase == “ended” check in the button event function. If you do not, that function will execute that code twice.
In the case of what you are doing here that probably won’t cause issues, but not doing that event.phase check can often lead to hard to find bugs,
local myData = {} myData.var1 = "textbox text" return myData
local composer = require( "composer" ) local scene = composer.newScene() local widget = require( "widget" ) local myData = require( "myData" ) function scene:create( event ) local sceneGroup = self.view local textBox = native.newTextField( 150, 150, 180, 30 ) --button function local function onBtnSend( event ) if event.phase == "ended" then -- if you want to assign the text from the textbox to the myData.var1 -- myData.var1 = textBox.text -- if you want to assign the myData.var1 to the textBox textBox.text = myData.var1 print( myData.var1 ) end return true end --btnSend local btnSend = widget.newButton { width = 150, height = 40, defaultFile = "btnSend.png", onEvent = onBtnSend } btnSend.x = 235 btnSend.y = 445 end function scene:show( event ) local sceneGroup = self.view end function scene:hide( event ) local sceneGroup = self.view end function scene:destroy( event ) local sceneGroup = self.view end --------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) ----------------------------------------------------------------------------------------- return scene
here are some ‘sample code’ links to check out:
https://coronalabs.com/resources/tutorials/sample-code/
https://coronalabs.com/samples/