Page 1 of 1

Changing Substacks on Runtime

Posted: Sat Jun 30, 2012 12:15 pm
by endernafi
Hi there LiveCoders,


I want to go from a substack to another while my app is running.
I know that the related commands are "close stack", "open stack", "go stack", "set the defaultStack to".
But my app doesn't react any of these commands while running.
What is the correct way to do this?

Here is some background explanation:
I use 4 different substacks, namely:
* forRetinaV
* forRetinaH
* forNonRetinaV
* forNonRetinaH
{V for Vertical & H for Horizontal}

On startup, it's not a problem.
If the device has a retina display, I choose the substack "forRetina" by a special handler;
and if the device has a standard display, I choose the substack "forNonRetina".
Here is my handler:

Code: Select all


on preOpenStack
.
..
...
determineTheStack tDeviceType
...
..
.
end preOpenStack

on determineTheStack pDeviceType
   switch pDeviceType
      case "simulatorDemo"
         close stack "myMainStack"
         go stack "forNonRetinaV"
         set the defaultStack to "forNonRetinaV"
         break
      case "nonRetinaScreen"
         iphoneSetAllowedOrientations "portrait"
         close stack "myMainStack"
         go stack "forNonRetinaV"
         set the defaultStack to "forNonRetinaV"
         break
      case "retinaScreen"
        iphoneSetAllowedOrientations "portrait"
         close stack "myMainStack"
         go stack "forRetinaV"
         set the defaultStack to "forRetinaV"
         break
   end switch
end determineTheStack
But I want to expand this handler to react orientation changes and some other detailed stuff.
While my app is running, i.e. after startup, it doesn't react to these commands.
Any help & idea appreciated.

Thanks,


~ Ender Nafi

Re: Changing Substacks on Runtime

Posted: Sat Jun 30, 2012 2:25 pm
by Dixie
Just looking quickly at your script... open the stack you want to go to before closing the stack that you are already in... I haven't tested this but I think that this might help you..

Code: Select all

on determineTheStack pDeviceType
   switch pDeviceType
      case "simulatorDemo"
         go stack "forNonRetinaV"
         close stack "myMainStack"
         set the defaultStack to "forNonRetinaV"
         break
      case "nonRetinaScreen"
         --iphoneSetAllowedOrientations "portrait"
         go stack "forNonRetinaV"
         close stack "myMainStack"
         set the defaultStack to "forNonRetinaV"
         break
      case "retinaScreen"
         --iphoneSetAllowedOrientations "portrait"
         go stack "forRetinaV"
         close stack "myMainStack"
         set the defaultStack to "forRetinaV"
         break
   end switch
end determineTheStack
be well

Dixie

Re: Changing Substacks on Runtime

Posted: Sat Jun 30, 2012 2:26 pm
by Klaus
Hi Ender,

you might want to catch the "orientationChanged" message.
Check the "iOS Release Notes", LiveCode: Menu: Help


Best

Klaus

Re: Changing Substacks on Runtime

Posted: Sat Jun 30, 2012 3:53 pm
by endernafi
Hi there,

@Klaus,
I was catching "orientationChanged" message,
but I didn't know what to do in that handler.
Thanks though, I re-read "iOS Release Notes".

@Dixie,
I am well, Dixie, I am well thanks to you.
It worked like a charm;
Just a simple switch of lines and voila :)


Thanks again, both of you...



Regards,

~ Ender Nafi