How to assign a "return value" to the correct item? Scene A->X->A should return to an A-item, B->X->B to a B item.

Sorry if this is a trivial question but I actually don’t figure out how to handle this.
What I want to do is the following.

To enter numbers in various scenes I wrote my own numPad instead of using the native.textField.
So, my various number fields in different scenes are simply buttons instead of native.textFields.
When pushed, my numPad comes in showing some number Buttons and an OK Button. I can now enter a number and when pressing the OK-Button the numPad disappears again.

But I can’t figure out how to get the new number from the numPad into the various number fields.

So e.g: I have sceneA with the buttons A1, A2, A3 displaying a number as their text. (A3 = ui.newButton{...} A3:setText( value3 ) sceneA:insert(A3) ) Then I have a sceneB with the buttons B1, B2 and so on.

When A3 is pressed, the numPad is called. It’s easy to get the value of A3 into the numPad as I can send it as a parameter (showNumPad( value3) ). Now I can change the number inside the numPad, and when I’m finally pressing OK, the numPad disappears. But how does now sceneA or button A3 know about the new number of the numPad?

If numPad could generate an event that I could catch inside sceneA or if I could tell numPad where to return the value (showNumPad( A3, value3 ))? I believe this is a standard task but I really don’t know how this has to be done.

Thanks for your help.
[import]uid: 21480 topic_id: 33152 reply_id: 333152[/import]

This might help -

http://www.coronalabs.com/blog/2012/08/07/managing-state-between-scenes/

Dave [import]uid: 117617 topic_id: 33152 reply_id: 131739[/import]

Hi Dave,

thank you for your reply. Unfortunately this doesn’t help me. Or shall the calling button write his idendity into one of these pseudoglobals and the OK Button on the numPad parse for this value like:

[code]
storyboard.state = {}

Module A:

local function a3Released( event )
storyboard.state.item = “a3”
storyboard.state.value = a3.text
storyboard.gotoScene( “numPad”, … )
end
Module numPad: (changes storyboard.state.value)

local function okReleased( event )
if storyboard.state.item = “a3” then
storyboard.gotoScene(“A”, …)
a3:setText( scene.value )
elseif storyboard.state.item = “b1” then

elseif … elseif … elseif … end
end[/code]

looks a little bit oldschool to me.

Any suggestions? Isn’t there a way to ask an event who was his sender and use this answer to return to the appropriate scene and the value to the appropriate item?

Thank you for your ideas! [import]uid: 21480 topic_id: 33152 reply_id: 131774[/import]

Ok I got it!!
Thank you.

I do it now like this:

storyboard.state = {}  
   
Module A:  
   
local function a3Released( event )  
 storyboard.state.item = a3  
 storyboard.state.value = a3.text  
 storyboard.gotoScene( "numPad", ... )  
end  
   
   
Module numPad: (changes storyboard.state.value)  
   
local function okReleased( event )  
 storyboard.state.item:setText( storyboard.state.value )  
end  

Don’t know how to return to the right scene now, but I’ll solve this by using numPad as an overlay.

[import]uid: 21480 topic_id: 33152 reply_id: 131784[/import]

Ok I got it!!
Thank you.

I do it now like this:

storyboard.state = {}  
   
Module A:  
   
local function a3Released( event )  
 storyboard.state.item = a3  
 storyboard.state.value = a3.text  
 storyboard.gotoScene( "numPad", ... )  
end  
   
   
Module numPad: (changes storyboard.state.value)  
   
local function okReleased( event )  
 storyboard.state.item:setText( storyboard.state.value )  
end  

Don’t know how to return to the right scene now, but I’ll solve this by using numPad as an overlay.

[import]uid: 21480 topic_id: 33152 reply_id: 131785[/import]

This might help -

http://www.coronalabs.com/blog/2012/08/07/managing-state-between-scenes/

Dave [import]uid: 117617 topic_id: 33152 reply_id: 131739[/import]

Hi Dave,

thank you for your reply. Unfortunately this doesn’t help me. Or shall the calling button write his idendity into one of these pseudoglobals and the OK Button on the numPad parse for this value like:

[code]
storyboard.state = {}

Module A:

local function a3Released( event )
storyboard.state.item = “a3”
storyboard.state.value = a3.text
storyboard.gotoScene( “numPad”, … )
end
Module numPad: (changes storyboard.state.value)

local function okReleased( event )
if storyboard.state.item = “a3” then
storyboard.gotoScene(“A”, …)
a3:setText( scene.value )
elseif storyboard.state.item = “b1” then

elseif … elseif … elseif … end
end[/code]

looks a little bit oldschool to me.

Any suggestions? Isn’t there a way to ask an event who was his sender and use this answer to return to the appropriate scene and the value to the appropriate item?

Thank you for your ideas! [import]uid: 21480 topic_id: 33152 reply_id: 131774[/import]

Ok I got it!!
Thank you.

I do it now like this:

storyboard.state = {}  
   
Module A:  
   
local function a3Released( event )  
 storyboard.state.item = a3  
 storyboard.state.value = a3.text  
 storyboard.gotoScene( "numPad", ... )  
end  
   
   
Module numPad: (changes storyboard.state.value)  
   
local function okReleased( event )  
 storyboard.state.item:setText( storyboard.state.value )  
end  

Don’t know how to return to the right scene now, but I’ll solve this by using numPad as an overlay.

[import]uid: 21480 topic_id: 33152 reply_id: 131784[/import]

Ok I got it!!
Thank you.

I do it now like this:

storyboard.state = {}  
   
Module A:  
   
local function a3Released( event )  
 storyboard.state.item = a3  
 storyboard.state.value = a3.text  
 storyboard.gotoScene( "numPad", ... )  
end  
   
   
Module numPad: (changes storyboard.state.value)  
   
local function okReleased( event )  
 storyboard.state.item:setText( storyboard.state.value )  
end  

Don’t know how to return to the right scene now, but I’ll solve this by using numPad as an overlay.

[import]uid: 21480 topic_id: 33152 reply_id: 131785[/import]