Hi All,
What should be an easy piece of code that has worked before isn’t working now.
A button press which works fine (it seems!), prints to the console as below and then instructs the textbox to be removed…but doesn’t on the latest daily build, the current stable release in the simulator or iPad physical device.
Please can someone shed some light on this for me?
The referenced “Easier1” is a global variable defined in main.lua to hold text entries across all composer scenes.
local storyboard = require("composer"); local scene = storyboard.newScene(); local g=""; local txtEasier1=""; function scene:create() g = self.view; --main background local bg = display.newImage(g,"i/bgStep5.png",0,0,768,1024); -- control buttons --back local btn\_Back = display.newImage( g,"i/btnBack.png", -30, 400, 70, 70, true ) btn\_Back.width=70; btn\_Back.height=70; function btn\_Back:touch(event) if event.phase == "ended" then if txtEasier1 ~= nil then print("removing text") Easier1 = txtEasier1.text; txtEasier1:removeSelf(); txtEasier1=nil; end storyboard.gotoScene("step4", "slideRight",sceneTransition); end end btn\_Back:addEventListener("touch"); end
My code adds a new textbox on scene show:
function scene:show() txtEasier1 = native.newTextBox( 142, 287, 485, 376) txtEasier1.isEditable=true; txtEasier1.text=Easier1; native.setKeyboardFocus(txtEasier1); end
Many thanks
Chris