overlay params?

7 replies [Last post]
schizoid2k
User offline. Last seen 9 hours 38 min ago. Offline
Joined: 29 Dec 2011

Does hideOverlay support passing parameters back to the calling scene? For instance, an overlay that pops up a few buttons, and the user presses one... would be nice to get that passed back.

If this is currently not possible, could you consider adding that in a future update?

Replies

leonZak
User offline. Last seen 39 weeks 6 days ago. Offline
Joined: 1 Nov 2011

I second this. I was just going to write something and saw this post.
I have this in my overlay scene:

1
2
3
4
5
6
7
8
9
10
local function onSceneTouch(event )
  local options = { 
    effect = "fade",  
    time = 500, 
    params =  { 
      whatWasSentBack = "Added text to " .. theInputText
    }
  }
  storyboard.hideOverlay(options)
end

Then in my calling scene I have this:

1
2
3
4
5
6
7
8
function scene:overlayEnded(event)
  local params = event.params
  -- print("Params is: " .. params.whatWasSentBack)
  tInput = native.newTextField ( 105, 300, 130, 25 )
  tInput.text = params.whatWasSentBack        -- line 57
  tInput:setTextColor(0)
  tInput.size = 14
end

I thought this should have the passed text, but get nothing back and get this:
scene1.lua:57: attempt to index local 'params' (a nil value)

thanks for any help.

schizoid2k
User offline. Last seen 9 hours 38 min ago. Offline
Joined: 29 Dec 2011

Yes... I am finding that as well. So I guess you cannot pass params back to the calling scene from the overlay. CoronaLabs... please consider this. Overlays make a nice pop-up dialog.

leonZak
User offline. Last seen 39 weeks 6 days ago. Offline
Joined: 1 Nov 2011

schizoid2k - I just checked the docs (http://docs.coronalabs.com/api/library/storyboard/hideOverlay.html) and there is no mention of returning options in the hideOverlay as there is with showOverlay. To be honest I didn't read the hideOverlay before just assumed it would be like showOverlay.

Seems logical - I thought it was a good way to present things like buttons, pickerwheel, etc. Get the user input and pass the info back. I do it now with gotoScene. What methods are others using to pop up to get user input ?

Docs are like toilet paper - don't need it till your in the pooh - then you REALLY need it.

leonZak
User offline. Last seen 39 weeks 6 days ago. Offline
Joined: 1 Nov 2011

dbl clicked

ingemar
User offline. Last seen 35 min 50 sec ago. Offline
Joined: 20 Jun 2011

You *could* attach your own data to the storyboard object in your overlay, something like:
storyboard.myReturnedButton="button1"

...and then in the overlayEnded function in the calling module check the value

1
2
3
4
5
6
function scene:overlayEnded(event)
        local group = self.view;
        local overlay_name = event.sceneName;   
 
        print(storyboard.myReturnedButton);
end

schizoid2k
User offline. Last seen 9 hours 38 min ago. Offline
Joined: 29 Dec 2011

@ingemar... that's exactly what I am doing now. I create a return variable in the storyboard object.

Would be nice to have params returned though... seems like a cleaner approach.

ingemar
User offline. Last seen 35 min 50 sec ago. Offline
Joined: 20 Jun 2011

Agreed. Would be cleaner...

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.