Having troubles with multiple orientations [solved]

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
paskr18
Posts: 5
Joined: Mon Oct 01, 2018 12:42 pm

Having troubles with multiple orientations [solved]

Post by paskr18 » Tue May 25, 2021 3:06 pm

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
Last edited by paskr18 on Tue May 25, 2021 5:59 pm, edited 1 time in total.

paskr18
Posts: 5
Joined: Mon Oct 01, 2018 12:42 pm

Re: Having troubles with multiple orientations

Post by paskr18 » Tue May 25, 2021 5:58 pm

Hi everyone,

I was able to find a solution to my issue.

Regards,

paskr18

trevix
Posts: 1026
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: Having troubles with multiple orientations [solved]

Post by trevix » Wed Aug 18, 2021 9:02 am

Can you please post it?
I am struggling with the same problem...
Regards
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9960
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Having troubles with multiple orientations [solved]

Post by FourthWorld » Wed Aug 18, 2021 9:57 am

Use the resizeStack message as the trigger.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

andresdt
Posts: 154
Joined: Fri Aug 16, 2019 7:51 pm
Contact:

Re: Having troubles with multiple orientations [solved]

Post by andresdt » Wed Aug 18, 2021 2:11 pm

I would use resizeStack as @FourthWorld says and also the preOpenCard of each stack that has a specific orientation.
Be kind, we all have our own wars.

trevix
Posts: 1026
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: Having troubles with multiple orientations [solved]

Post by trevix » Wed Aug 18, 2021 3:35 pm

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.
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

Post Reply

Return to “Android Deployment”