New in 14: Allowed orientations 2 - set triggers

Version 3

     

     

     

     

    After you have written a script that uses the Set Allowed Orientations script step, the next step is to implement this script in your FileMaker Go workflow. A typical approach is to trigger the script in some fashion. Here are some possibilities:

     

    • OnFirstWindowOpen runs when the first window of the file is opened. You can use this to limit the allowed orientations for the entire solution.


    • OnLayoutEnter runs after the layout is loaded. This could limit allowed orientations for this specific layout.


    • OnLayoutExit runs before the layout is exited. This could permit all orientations after leaving this specific layout.


    • OnRecordLoad runs after a record is made current or entered. This could limit or permit allowed orientations based on the contents of one or more fields in the record.


    • OnModeEnter runs after a change of mode (either manually or in a script). This could limit or permit allowed orientations for a specific mode.


     

    In the example solution, when the user wants to view Approval details in FileMaker Go, FileMaker Go chooses between two layouts:


    • Approvals Detail | Go - IMAGES, used for reviewing image files like JPGs
    • Approvals Detail | Go - MEDIA, used for reviewing video or audio files


    Let's say you've decided that the "MEDIA" layout is best viewed in portrait orientation since the comments are more visible that way. You'll use your new "Trigger | Set Allowed Orientations [orientation] " script to allow only portrait orientation when this layout is entered.

     

     


     

     

    Goal:

     

    Observe how the "Approvals Detail | Go - MEDIA" layout permits all orientations when viewed in FileMaker Go.


    Then use FileMaker Pro to set up the layout’s script triggers so that when the user enters the layout, the script is called with the parameter "portrait". When the user exits the layout, the script is called again but with the parameter "all".


    Finally, return to FileMaker Go and enter the same layout again, observing how the orientation is locked when the layout is entered, and how all orientations are permitted when the layout is exited.


     

    Note:

     

    This page builds on the previous one, "Allowed orientations: write script". However, you can start here if you use the "Trigger | Set Allowed Orientations [orientation] FINISHED" script in the exercise below.



    Before you start:

     

    Make sure you have the Approvals example solution open in FileMaker Pro 14 on your desktop or laptop. This machine should be on the same local network as your iPad so that it’s available on the iPad as a hosted file.



    Steps:

     

    • Try the layout in FileMaker Go

     

    1. Open the hosted Approvals solution on your iPad. A list of approval records is displayed.

    2. Tap the first approval record ("Running in the grass") to view the detail layout. Because this record contains a video, the record detail is displayed using the “Approval Details | Go - MEDIA” layout.


    1. Rotate the device from portrait to landscape orientation, then back to portrait, observing that the layout displays in both orientations.

      Now let’s change this behavior so that the layout stays locked in portrait orientation.


      Set up the triggers for the layout

    2. Switch to FileMaker Pro 14 on your desktop or laptop.

    3. Choose the File menu > Manage > Layouts...  (⇧⌘L or Ctrl L).  A Manage Layouts (Approvals) dialog window appears.

    4. Double-click the “Approval Details | Go - MEDIA” layout (in the Go folder). A Layout Setup dialog window appears.

    5. Select the Script Triggers tab.

    6. Select the OnLayoutEnter checkbox in the list of events.

    7. For the Script: option, click the Select… button. A Specify Script dialog window appears.

    8. Select the “Trigger | Set Allowed Orientations [orientation]” script that you created in the previous lesson. (Don't double-click since you'll need to enter a script parameter).

    9. For the Optional script parameter, enter the value: portrait
      565-script+trigger+portrait+parameter.png

    10. Click the OK button to save your changes and close the Specify Script dialog window.

    11. Repeat steps 6 to 10 for the OnLayoutExit checkbox in the list of events, choosing the same script — but for the optional script parameter, enter the value: all

    12. Click the OK button to save your changes and close the Layout Setup dialog window.

    13. Enter Browse mode to save your changes to the layout.

    14. Close the Manage Layouts dialog window.


      Try the layout again in FileMaker Go


    15. Return to your iPad.

    16. Tap the arrow in the upper left of the screen to return to the Approvals list layout.

    17. Tap the first approval record to view it again. As before, because the record contains a video, the "Approval Details | Go - MEDIA" layout is displayed. This is the layout with the triggers you just set up. The OnLayoutEnter trigger script runs immediately after the layout is displayed.

    18. Rotate the device, observing that the layout stays locked in portrait orientation.

    19. Tap the circled arrow in the upper left of the screen to return to the Approvals list layout. The OnLayoutExit trigger script runs before you leave the "Approval Details | Go - MEDIA" layout then the layout change takes place.

    20. Rotate the device to confirm that the Approvals list can be viewed in both portrait and landscape.