Page 1 of 1

Having troubles with multiple orientations [solved]

Posted: Tue May 25, 2021 3:06 pm
by paskr18
Hello everyone,

I am working on an app that has one main stack and several substack. The orientation of the main stack is portrait and the orientation for the substacks are landscape. In the stack script, I have imposed the orientation for the stacks.
When I call a substack it opens with the proper orientation. But when I close the substack, all the objects are now all the way down of the main stack and the orientationChanged handler is not deal with.
I am using Livecode Community Plus 9 on a Windows 10 laptop.

on the main stack script
on preOpenStack
if the environment is "mobile" then
mobileSetAllowedOrientations "portrait"
set the fullScreenMode of me to "exactfit"
set the acceleratedRendering of me to true
mobileLockIdleTimer
mobileSetFullScreenRectForOrientations "portrait","0,0,414,736"
end if
end preOpenStack

on the substack script
on openStack
if the environment is "mobile" then
mobileSetAllowedOrientations "landscape left"
mobileSetFullScreenRectForOrientations "landscape left","0,0,960,540"
set the fullScreenMode of me to "exactfit"
set the acceleratedRendering of me to true
end if
end openStack

Regards,

paskr18

Re: Having troubles with multiple orientations

Posted: Tue May 25, 2021 5:58 pm
by paskr18
Hi everyone,

I was able to find a solution to my issue.

Regards,

paskr18

Re: Having troubles with multiple orientations [solved]

Posted: Wed Aug 18, 2021 9:02 am
by trevix
Can you please post it?
I am struggling with the same problem...
Regards

Re: Having troubles with multiple orientations [solved]

Posted: Wed Aug 18, 2021 9:57 am
by FourthWorld
Use the resizeStack message as the trigger.

Re: Having troubles with multiple orientations [solved]

Posted: Wed Aug 18, 2021 2:11 pm
by andresdt
I would use resizeStack as @FourthWorld says and also the preOpenCard of each stack that has a specific orientation.

Re: Having troubles with multiple orientations [solved]

Posted: Wed Aug 18, 2021 3:35 pm
by trevix
mmmh...
I am having no problem on going from landscape, in the main stack, to portrait in the substack using the script below.
I cannot make it run when, as in my case, I am trying to implement notifications and show them in a portrait card while the rest of the app runs in landscape (works on Android, not on iOS)

Code: Select all

On Preopenstack --Main stack script
     if "lib_notifications" is not in the stacksinUse then start using stack "lib_notifications" --where all the notification stuff is
     if the environment = "mobile" then
          set the rect of this stack to the screenRect
          set the fullscreenmode of this stack to "letterbox"
          mobileSetAllowedOrientations "landscape left,landscape right"
          if the platform is "iPhone" and iphoneGetNotificationBadgeValue() > 0 then
               retrieveNotification  --this script is in the lib_notifications library and essenzially go to the substack where it shows the notification
          end if
     end if
end Preopenstack

on pushNotificationReceived pMessage
     retrieveNotification --this script is in the lib_notifications library and essenzially go to the substack where it shows the notification
end pushNotificationReceived
The script of the substack card:

Code: Select all

on PreopenCard
     if the environment = "mobile" then
          mobileSetAllowedOrientations "portrait,portrait upside down"
          set the fullscreenmode of this stack to "letterbox"
          --mobileSetFullScreenRectForOrientations "portrait",0,0,tHeigth,tWidth
          --set the rect of this stack to 0,0, tHeigth,tWidth
     end if
end PreopenCard

on resizeStack pNewWidth, pNewHeight, pOldWidth, pOldHeight
     try
          set the width of fld "NotificationText" of me to pNewWidth - 24
          set the height of fld "NotificationText" of me to the formattedheight of fld "NotificationText" of me
          set the rect of widget "NotBrowser" of me to 0, the bottom of  fld "NotificationText" of me + 10, pNewWidth,pNewHeight
          pass resizeStack
     catch errorVariable
          put errorVariable into msg
     end try
end resizeStack
As I said, going from stack to stack, the windows turns fine, since the preopenstacks are running (I close the substack on leaving).
But when the standalone is launched by the notification received, the PreOpencard and resizestack of the substacks don't run.
The substack has only 1 card.