Page 1 of 1
Execution Error on orientationChanged message
Posted: Fri Jun 28, 2013 10:23 pm
by daryl
Folks,
I'm working with a Galaxy 2 tablet and trying to learn about device orientation. I added the following message handler as described in the dictionary:
on orientationChanged
put mobileDeviceOrientation() into theOrientation
updateInteface theOrientation -- update the interface to fit the new orientation
answer "Orientation is:" && theOrientation
end orientationChanged
and now I am getting the error: Execution Error on orientationChanged in an alert box.
The event handler is in the card that is being displayed.
Any help would be greatly appreciated.
Thanks,
Daryl
Re: Execution Error on orientationChanged message
Posted: Sat Jun 29, 2013 1:10 am
by Mark
Hi Daryl,
I suspect there's a typo in the documentation. Inteface should probably interface. Does that solve the problem?
Kind regards,
Mark
Re: Execution Error on orientationChanged message
Posted: Sat Jun 29, 2013 8:59 pm
by jacque
There is a misspelling in the dictionary and I think it should be "updateInterface" too, but that wouldn't cause the error. It's a cusom handler name that isn't included in the short example, so it could be called anything.
The error is more likely that daryl's script doesn't have a handler named "updateInterface" or even "updateInteface".
Re: Execution Error on orientationChanged message
Posted: Mon Jul 01, 2013 6:02 pm
by daryl
Hi Jacque and Mark and thanks for your replies. Both of you were right, once I added the updateInterface handler the error message stopped and the tablet display actually changes to the correct orientation. However I'm still having a problem during startup in that whatever way I am holding the tablet LiveCode reports it as being in portrait mode, and for example the splash screen gets displayed in the wrong orientation. I there some way to have LiveCode check the initial orientation on startup? I am checking if the environment setting in the Mainstack's preOpenCard handler and if it's mobile I then set the allowed orientations using mobileSetAllowedOrientations. I have put the orientationChanged handler in the Mainstack, as well as the splash screen card and the main card that gets displayed at the end of the startup process, but the initial display is always in portrait mode, regardless of the tablet's orientation. I am testing this on a Galaxy tablet tethered to my desktop via a usb connection, in case that makes any difference.
Thanks again,
Daryl
Re: Execution Error on orientationChanged message
Posted: Thu Jul 04, 2013 11:38 am
by Mark
Hi Daryl,
The splash screen is displayed before any scripts run. Therefore you can't adjust its orientation by script. You can only change the initial orientation in the standalone application settings window.
Kind regards,
Mark
Re: Execution Error on orientationChanged message
Posted: Fri Jul 05, 2013 8:35 pm
by jacque
Mark's reply is correct for iOS, which shows the splash before the app loads, but since Android doesn't support separate splash screens, you have more options there. Since you're using the first card of your stack as a fake splash screen, all the normal messages will be sent and scripts can respond to them.
You can create two images on that card, one of which is rotated 90 degrees for a landscape display. Check the orientation in a preOpenCard handler in the first card (use mobileOrientation() to get that) and show the correct image. Hide the one that isn't being used. If you get an "upside down" orientation, you can rotate the correct image in the same handler if you want to go that far.
Re: Execution Error on orientationChanged message
Posted: Fri Jul 05, 2013 9:16 pm
by daryl
Mark and Jacque,
Thanks for your replies. I have commented out the "go to splashcreen card" in the mainstack's on OpenStack, and put in the following:
put mobileOrientation() into tOrientation
answer "the orientations is" && tOrientation
as the very first statement in the on OpenStack of the mainstack script. Unfortunately the answer is always portrait no matter which way I hold the tablet.
After the script goes to the main display card, the on orientationChanged handler does report the correct orientation.
I'm just not sure if this is expected behavior, or what....
Regards,
Daryl
Re: Execution Error on orientationChanged message
Posted: Fri Jul 05, 2013 10:10 pm
by jacque
It isn't what I'd expect, but I haven't actually had time to test it. Querying orientation on openstack may be too early in the sequence though, which is why I suggested using a preOpenCard handler in the script of the first card. You can leave your original openstack handler in place if you want, though strictly speaking you don't need it at all if the first card is the splash, because stacks always open to the first card by default.
If it doesn't work in preOpenCard, then try sending the query in a short amount of time:
on preOpenCard
send "setupOrientationSplash" to me in 1 millisecond
end preOpenCard
on setupOrientationSplash
answer "orientation is:" && mobileOrientation()
end setupOrientationSplash
If that still doesn't work, I'd classify it as a bug because all messaging should be functional by then. What do you get if you just add a button to the first card that responds with the orientation?
Re: Execution Error on orientationChanged message
Posted: Fri Jul 05, 2013 11:04 pm
by daryl
Hi Jaques, Based on your response I'm starting to think this is indeed a bug. I put in the timed send command and still got the wrong orientation from mobileOrientation(). I increased the time over several iterations until I got to 1 second with the same result.
If you get some time, could you try to duplicate the problem on your end? If you get the same result, I will file a bug report.
Thanks,
Daryl
Re: Execution Error on orientationChanged message
Posted: Thu Jul 18, 2013 7:28 pm
by sgilito
Hi,
I'm using the following code:
on OrientationChanged
mobileUnlockOrientation
answer "Orientation:" & mobileDeviceOrientation() & " Locked:" & mobileOrientationLocked() with "Ok"
end OrientationChanged
This code send the correct massage for each orientation, but my card layout remains in portrait mode.
I'm looking the way to change the card layout to to the device orientation.
Any idea about it?
Sgil
Re: Execution Error on orientationChanged message
Posted: Thu Jul 18, 2013 7:55 pm
by jacque
The orientationChanged message is sent before the screen actually changes; it tells you that the screen is ready to change. The resizeStack message is sent after the rotation is complete. So to change your layout, do it in a resizeStack handler.
Re: Execution Error on orientationChanged message
Posted: Thu Jul 18, 2013 7:59 pm
by Dixie
try using something like this...
Code: Select all
on orientationChanged
end orientationChanged
on resizeStack
if "portrait" is among the words of iphoneDeviceOrientation() then
/*do stuff here */
exit resizeStack
end if
if "landscape" is among the words of iphoneDeviceOrientation() OR "face" is among the words of iphoneDeviceOrientation() then
/*do stuff here */
end if
end resizeStack