Just For Fun:  Triggering a script on iPad rotation

Discussion created by steve_ssh on Jul 28, 2012
Latest reply on Aug 9, 2012 by ebloom29

Just for fun:


I decided to see if I could realize a means for detecting iPad orientation changes which does not utilize an OnTimer script, or a looping script, i.e. something which doesn't require a FileMaker script to perform constant checking of the device's current orientation.



The ideas that I wanted to work with were as follows:


1) Layout objects which are anchored on two opposing sides are resized when the device is rotated.


2) FM Go webviewer objects which are asleep are awakened upon being resized.


3) FM Go webviewer objects which are awake can detect and respond to resize events.


4) In response to either being awakened or receiving notification of a resize event, a webviewer can run custom Javascript.


5) In FM Go 12, we can utilize Javascript in a webviewer to trigger a FileMaker script by using the FMP URL protocol.



How well did this work?


Using FM Go 12, on a first-generation iPad running iOS 5 it seems to work fairly well. There were a couple of times that, by performing a flurry of constant rotations and partial rotations of the device, I faked it out, and it was not able to keep up with my sequence of actions. Other than that, it seems to perform as desired on my device. I don't know how well (or even if) this works on more recent iPad models and/or other iOS versions.



Would I utilize this technique in a real solution?


Under most circumstances, I would not use this technique for a real solution. While I really like the fact that it doesn't require any periodic/looping FileMaker script, this technique is directly tied to the iOS webkit, and it is also closely tied to undocumented (subject to change) behavior of the FM webviewer. As such, either an FM upgrade or an OS upgrade has the potential to break this technique.



I'm attaching a sample file for anyone who would like to take a look.


Hope everyone is having a great weekend.