Thank you for your post.
FileMaker Go is able to use Get (ScreenHeight) and Get (ScreenWidth) to let you know if you are in Portrait or Landscape. However, at this time, there is no built-in "OnLandscape" or "OnPortrait" function. One (not-so-elegant) option is to use Install OnTimer Script and check every "x" seconds to see if there was a switch between Portrait/Landscape and then switch to the appropriate Layout. That is, check Get (ScreenWidth) against the last saved value. If different, update the value and switch to the desired Layout.
I encourage you to enter this suggestion into our Feature Requests web form at:
These web form suggestions are read by our Development and Product Management departments where they are then discussed and considered for a future release. Although I could copy your post and paste it into the web form, there are a couple of questions asked that only you can answer.
OK, will do. I can see this being useful for other people.
What if you had an unstored calculation field that used the window dimensions to determine device orientation and returned the ID number of a different related image whose dimensions corresponded with the current orientation? Then a container field formatted with Top, left alignment from this related table might be placed in the background with appropriate anchors to resize the container field as needed. Don't know if you'd hit a screen refresh issue, but it might be worth an experiment or two...
The suggestion of using Get (ScreenHeight) and Get (ScreenWidth) seems like a good one, but these functions don't actually report the orientation of the device as expected.
When my iPhone 3GS is held in portrait orientation, the Get (ScreenHeight) and Get (ScreenWidth) reports 460 h × 320 w. When held in landscape orientation, it reports 480 h × 300 w. That ought to be 300 h × 480 w. The discrepancy between the two numbers can be attributed to the FMGo Window Name bar at the "top" of the screen, but notice that the height and width number are confused for the landscape mode.
This is a bug (at least to my mind) that I mentioned before that makes it more difficult to determine which way the device is held, though not impossible with a workaround that looks for the 20 pixel difference.
Similarly, on an iPad, portrait is reported as 1004 h × 768 w, while landscape is erroneously reported as 1024 h × 748 w. To be clear, the landscape report should be 748 h × 1024 w.
Another thing to ask for on the Feature Request would be a OnOrientationChange event script trigger or, (if the Get() functions were fixed) more generically, an OnWindowSizeChange event.
Troy Meyers (et al):
Good catch! After some further testing, use Get (WindowContentWidth) and Get (WindowContentHeight) instead.
On an iPhone4, height is 416 and width is 320 in Portrait, and height is 286 and width is 480 in Landscape.
Thank you, I'll put that to use, Get (WindowContentWidth) and Get (WindowContentHeight) works well. With a FileMaker window-name bar showing, I get these:
iPhone 3GS portrait: 460 h × 320 w
iPhone 3GS landscape: 320 h × 480 w
I hadn't noticed it before, but in this iPhone the "AT&T" etc. bar at the top displays in Portrait but not Landscape view, unless the device is in that orientation to begin with.
iPad portrait: 973 h × 768 w
iPad landscape: 717 h × 1024 w
On the iPad the "AT&T" bar displays in either orientation.
Interestingly, if done as an unstored calculation and displayed on the screen, the values update dynamically when the device is rotated. This was NOT the case when using either the Get (ScreenHeight) and Get (ScreenWidth) pair or the Get (WindowHeight) and Get (WindowWidth) pair -- the values don't change unless the window is closed and reopened, and both sets (all four) of those calculations have the problem of mixing height and width when in landscape view.
For some reason, Get (WindowContentWidth) and Get (WindowContentHeight) doesn't have that problem, and will also dynamically update as you rotate the device.
I did (not very hopefully) see if I could get a displayed calculation field to fire an OnObjectModify script to change the layout, but that doesn't work. I'm not too surprised, having a change in a calculated field value fire a script could be too "dangerous" to allow. So, an OnWindowSizeChange event for the layout in addition to the existing layout script triggers would be good.
Is it not possible to check if one value is greater than the other to determine if it is portrait or landscape?
Thank you for your post.
Since Get (WindowContentWidth) and Get (WindowContentHeight) will give you values, you can definitely check to see if one is greater than the other.
I'm still voting for a OnWindowSizeChange event so that we know when a user changes orientation in iOS. From the desktop version of FileMaker it would still have value... if the user changes his screen resolution.