Without seeing your scripts and having more information it's difficult to pinpoint. One thing to consider is wrapping your "orientation" script (second script you mention) in a IF statement to check device type before triggering the OnLayoutSizeChange event. E.g. IF device is iPad or iPhone do this stuff; Else Exit script (or go to a different layout, etc.)...
If your first script is working as desired I think you have the needed script steps to draw from for determining device type.
IF [ Get ( Device ) = 4 ] //Indicates iPhone
//Do something here for iPhone
Exit Script or Go to Layout X, etc.
The important thing about the actions that cause the trigger is the "When a window is first opened"
You will have to figure out a way to allow the trigger to process on the layout in question when you want it to or redesign the layouts to leverage object anchors so don't need separate layouts for each orientation.
This is a post process trigger so it cant be aborted with return = true.
Thanks coherentKris, that reference seems to supply the answer. The OnLayoutSizeChange triggers automatically when the file is opened. Guess I'll have to look at a different method of triggering.
OnLayoutSizeChange is specifically attached to a layout. If you dont go that layout on first open the trigger wont fire.
But it does. My script is specifically attached to that layout but reading the article that you posted a link to, one of the actions that triggers the script is the opening of the file.
OnLayoutSizeChange script trigger that triggers a script to run after a layout or window has changed size as a result of the following:
- Rotating the iOS device
- Hiding or showing the status toolbar
- When a window is first opened
- User interaction
- Script / script step
- Hiding or showing the status toolbar via menu command, shortcut or script step
- Hiding or showing the formatting bar via menu command, shortcut, or script step
- When a window is first opened
So what is happening is that the original Get Device script runs, followed immediately by the OnLayoutSizeChange script because in effect the layout is changing size.
One the file is open the OnLayoutSizeChange script performs normally. Perhaps I might get this script to call the opening script after it has been run, which might then return me to the intended opening screen but that seems a bit messy.
Interesting though, I have another OnLayoutSizeChange script attached to another pair of layouts and this does not run at startup.
2 of 2 people found this helpful
This is a great blog post with an excellent demo file that demonstrates how events fire in order and when. It's a great sandbox to get to know all the triggers. If you are uncertain which events will fire when you do something, just try it in the demo file.
In my applications which support iOS devices, I determine the device type on file open and send the user to the appropriate layout (for Desktop, iPad or iPhone). Then, from this device-appropriate layout I run any scripts for that environment, and navigation to other layouts stays within layouts for that specific device type. This is where I would put your orientation trigger. YMMV
That's sort of what I'm doing. I have the script for determining the device run at startup and it works fine.
The second script is designed to change between a list view and a form view on the phone so that in vertical mode the form shows and in horizontal the list view. Again it works fine once everything is open and running. However the action of opening the file triggers the OnLayoutSizeChange script whether I want it to or not and independent of any layout that it is attached to.
I've tried deleting the second script and everything then works fine, the layouts are displayed according to the device. I just now need to find a different way to script the layout change when the device is rotated.
If the OnLayoutSizeChange script trigger is only on the layouts specifically designed for mobile, you should be able to isolate this behavior. Unless you're applying to the first mobile window that opens. Then you'll have the conflict you're describing. In my case(s) each device type has launch page that allows user to determine their next operation, i.e. go to Sales, Inventory, Customers, etc.; or it's controlled by account name or permission set (e.g. Customer Service vs Laboratory, etc.). In my cases I don't use the orientation resize on this launch layout because it's mostly iPhone in one case and portrait mode works best for that step. Then it can be used on the other layouts.
The key is that you'll want to apply that trigger to layouts after the first window opens. Maybe I'm missing something in your use case.
Sounds like your second script needs to use get ( WindowOrientation ) to identify whether you are in portrait or landscape before altering the view.
The solution I'm working on is designed as a reference tool and so user interaction is kept to a minimum. There is no editable data in the mobile version. I'm using the OnLayoutSizeChange script trigger to offer users an alternative view of the data, for example a search feature in vertical mode and a list view in horizontal mode.
"If the OnLayoutSizeChange script trigger is only on the layouts specifically designed for mobile,"
"In my case(s) each device type has launch page that allows user to determine their next operation, i.e. go to Sales, Inventory, Customers, etc.;"
I have similar. In the case of this solution there is a 'home' screen for the mobile device that has a series of buttons that go to different parts of the solution. The mobile version is 'read only' so there are no login details required, all layout tools etc are locked so that the user has no access.
If the startup script detects that it is a Mac then a different screen is loaded to enable editing.
But I'm struggling to find a way of preventing the OnLayoutSizeChange script triggering at startup because (as the screenshot above shows) in both FileMaker Pro and FileMaker Go this script action is triggered automatically when the file is opened because in effect this does change the layout size.
Unless I'm missing something too.
Thanks. Yes, it already does. There isn't a problem with the script, the problem is preventing it triggering at start-up.
Yet if it checks the orientation, the fact that it triggers at start up shouldn't be a problem as it is then selecting the correct view for you.