Force Orientation Change to Landscape at StartUp
Posted: Tue Dec 23, 2014 3:45 am
LiveCode Mobile Developers,
I have an App that I want to work on both mobile phones and tables and I'm running into a challenge. I'm using LiveCode 6.7.1 rc4, but have had the same issue with previous versions.
I have the App set up to initially start in Portrait mode and have enabled the mobileAllowedOrientations to support any configuration.
Things work great on the phone when the initial orientation is Portrait, but I want app to come up in Landscape mode when it is installed on a tablet.
I'm trying to force the application to be in Landscape orientation without the user changing the device orientation to Portrait and then back to landscape. So force the Display Orientation = Landscape
I created the following function to try to force the orientation to change to Landscape on the first card, but when changes the stack orientation, the display orientation still remains in Portrait. The card has a scroll area that needs to re-adjusted as well.
Enter Device Orientation = "Landscape Right" Screen Orientation = "Portrait"
Enter Device Orientation = "Landscape Right" Screen Orientation = "Portrait"
so the stack resize doesn't do anything
The display goes from a full screen Portrait display to a portrait display that has two large black squares on each side.
So it looks like it has stretched the display to the landscape dimensions, but the applications still thinks it is in Portrait mode.
Is there any way to force the Screen Orientation to change without physically turning the device?
I have an App that I want to work on both mobile phones and tables and I'm running into a challenge. I'm using LiveCode 6.7.1 rc4, but have had the same issue with previous versions.
I have the App set up to initially start in Portrait mode and have enabled the mobileAllowedOrientations to support any configuration.
Things work great on the phone when the initial orientation is Portrait, but I want app to come up in Landscape mode when it is installed on a tablet.
I'm trying to force the application to be in Landscape orientation without the user changing the device orientation to Portrait and then back to landscape. So force the Display Orientation = Landscape
I created the following function to try to force the orientation to change to Landscape on the first card, but when changes the stack orientation, the display orientation still remains in Portrait. The card has a scroll area that needs to re-adjusted as well.
Code: Select all
function setDisplayOrientationToDevice
if environment() is not "mobile" then exit setDisplayOrientationToDevice
-- App defines the dimensions based on the device to fit the tablet or phone
put the uPortraitSize of this stack into tPortraitSize
put the uLandscapeSize of this stack into tLandscapeSize
-- Scroll area is sized based on the orientation
if scrollGroupID is not Empty then
put the uPortraitSize of scrollGroupID into tGroupPortraitSize
put the uLandscapeSize of scrollGroupID into tGroupLandscapeSize
else
put Empty into tGroupPortraitSize
put Empty into tGroupLandscapeSize
end if
put mobileDeviceOrientation() into tOrientation
put mobileOrientation() into tScreenOrientation
answer info "Enter Device Orientation = " & tOrientation && "Screen Orientation = " & tScreenOrientation
if tOrientation contains "portrait" then
if scrollID is not Empty AND tGroupPortraitSize is not Empty then
mobileControlSet scrollID, "rect", tGroupPortraitSize
end if
if tPortraitSize is not Empty then
answer info "Setting Stack to " & tPortraitSize
set the rect of this stack to tPortraitSize
end if
else if tOrientation contains "landscape" then
if tLandscapeSize is not Empty then
answer info "Setting Stack to Landscape " & tLandscapeSize
set the rect of this stack to tLandscapeSize
end if
if scrollID is not Empty and tGroupLandscapeSize is not Empty then
answer info "Setting Scroll Group to " & tGroupLandscapeSize
--set the rect of tScrollGroupID to tGroupLandscapeSize
mobileControlSet scrollID, "rect", tGroupLandscapeSize
end if
end if
put mobileDeviceOrientation() into tOrientation
put mobileOrientation() into tScreenOrientation
answer info "Exit Device Orientation = " & tOrientation && "Screen Orientation = " & tScreenOrientation
end setDisplayOrientationToDevice
Enter Device Orientation = "Landscape Right" Screen Orientation = "Portrait"
so the stack resize doesn't do anything
The display goes from a full screen Portrait display to a portrait display that has two large black squares on each side.
So it looks like it has stretched the display to the landscape dimensions, but the applications still thinks it is in Portrait mode.
Is there any way to force the Screen Orientation to change without physically turning the device?