Changing Substacks on Runtime

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Changing Substacks on Runtime

Post by endernafi » Sat Jun 30, 2012 12:15 pm

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
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Changing Substacks on Runtime

Post by Dixie » Sat Jun 30, 2012 2:25 pm

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

Klaus
Posts: 14183
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Changing Substacks on Runtime

Post by Klaus » Sat Jun 30, 2012 2:26 pm

Hi Ender,

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


Best

Klaus

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: Changing Substacks on Runtime

Post by endernafi » Sat Jun 30, 2012 3:53 pm

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
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

Post Reply