How to call/edit objects from a scene from an overlay

I have a settings overlay, and on my main page I have a native…newTextField, which is on top of everything, even the overlay (as it should be based on it being a native object).  So, what I am currently doing is hiding the textfield when I click the button to active the overlay, by using the textfield.isVisible = false…  My problem is, I can’t seem to get it to come back when closing the overlay.  I have a save and a cancel(close) button on the overlay, and I tried to add the textField.isVisible = true to that, but since its from a different scene it isn’t working.  

Is there away to edit an object that is on a different scene that is still open?

Yes you will need to pass a reference to the other scene in the params and then you can adjust the other scene

Ok, took a while to understand but I finally figured it out.  Thanks… 

Incase someone else is looking for this… this is how I did it (essentially). 

-------------------------- -- From "scene1.lua" -------------------------- local nameInput local textField local options = { isModal = true, params = {textField} } local function showOverlay() --Since the textField in params has not yet been assigned anything and is currently nil, need to make it = the textField options.params.textField = nameInput composer.showOverlay( "scene2", options ) end --in the show() function I created the newTextField as such... nameInput = native.newTextField( display.contentCenterX, letterNeededText.y+50, 150, 30 ) nameInput.placeholder = "Input Name Here!" sceneGroup:insert(nameInput) -------------------------- -- In "scene2.lua" -------------------------- local composer = require( "composer" ) local scene = composer.newScene() --initialize a local object within this new scene that can be set to the textField local nameInput --when close overlay is called later by some sort of close/save button it sets the textbox isVisible field to true function closeOverlay() nameInput.isVisible = true composer.hideOverlay() end function scene:create( event ) --Need to set our local object to equal the textField nameInput = event.params.textField end

or for a more OOP approach you could do this in scene1

--declare a function to process returned data from scene2 function processResponse(myData) ...do something with "myData" end --load scene2 composer.showOverlay( "scene2", {modal=true, params.callback=processResponse)

then in scene2

--store a reference to the callback in scene:create local referenceToScene1Function = event.params.callback --at a later time we want to pass data back so we simply call the stored callback function and pass in our data. --this could be on closing the scene or on a button handler referenceToScene1Function(myData)

Yes you will need to pass a reference to the other scene in the params and then you can adjust the other scene

Ok, took a while to understand but I finally figured it out.  Thanks… 

Incase someone else is looking for this… this is how I did it (essentially). 

-------------------------- -- From "scene1.lua" -------------------------- local nameInput local textField local options = { isModal = true, params = {textField} } local function showOverlay() --Since the textField in params has not yet been assigned anything and is currently nil, need to make it = the textField options.params.textField = nameInput composer.showOverlay( "scene2", options ) end --in the show() function I created the newTextField as such... nameInput = native.newTextField( display.contentCenterX, letterNeededText.y+50, 150, 30 ) nameInput.placeholder = "Input Name Here!" sceneGroup:insert(nameInput) -------------------------- -- In "scene2.lua" -------------------------- local composer = require( "composer" ) local scene = composer.newScene() --initialize a local object within this new scene that can be set to the textField local nameInput --when close overlay is called later by some sort of close/save button it sets the textbox isVisible field to true function closeOverlay() nameInput.isVisible = true composer.hideOverlay() end function scene:create( event ) --Need to set our local object to equal the textField nameInput = event.params.textField end

or for a more OOP approach you could do this in scene1

--declare a function to process returned data from scene2 function processResponse(myData) ...do something with "myData" end --load scene2 composer.showOverlay( "scene2", {modal=true, params.callback=processResponse)

then in scene2

--store a reference to the callback in scene:create local referenceToScene1Function = event.params.callback --at a later time we want to pass data back so we simply call the stored callback function and pass in our data. --this could be on closing the scene or on a button handler referenceToScene1Function(myData)