Hi guys,
I’m trying to make a scene where text is inputted into a text field then a button send is clicked which sends the inputted text to myData.lua which can then be displayed on the screen with a display.newText, I can see that myData.lua is working fine as I have a value entered which displays on the screen, the issue is that when something is entered into the text box and the button send is clicked nothing happens. Any Ideas?
[lua]
–my global space
local myData = {}
myData.var1 = “textbox text”
return myData
[/lua]
[lua]
local composer = require( “composer” )
local scene = composer.newScene()
local widget = require( “widget” )
local myData = require( “myData” )
function scene:create( event )
local sceneGroup = self.view
–input textbox
local textBox
textBox = native.newTextField( display.contentCenterX, 95, display.contentWidth-50, 30 )
textBox.placeholder = myData.var1
–text for Var1
local textVar1 = display.newText(myData.var1,
185, 170, display.contentWidth, display.contentHeight * 0.5, native.systemFont, 20 )
textVar1:setFillColor( 0, 0, 0 )
end
–btnSend
local btnSend = widget.newButton
{
width = 150,
height = 40,
defaultFile = “btnSend.png”,
onEvent = btnSend
}
btnSend.x = 235
btnSend.y = 445
–button function
local function btnSend( event )
myData.var1 = textBox.text
textBox.placeholder = myData.var1
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
– Listener setup
scene:addEventListener( “create”, scene )
scene:addEventListener( “show”, scene )
scene:addEventListener( “hide”, scene )
scene:addEventListener( “destroy”, scene )
return scene
[/lua]
Thanks again,
Matt.