Script Triggers Drawn Out (Updated for FileMaker 13)
A while back I wrote a blog post on how FileMaker 12 script triggers function.
Here's an update for FileMaker 13:
(Most of the writeup is the same, because, well, it still applies 🙂
There are quite a few nuances in how FileMaker script triggers function. Two of the more straightforward ones are the sequence that script triggers evaluate in (e.g. OnObjectKeystroke fires before OnLayoutKeystroke) and the timing of a script as compared to the event that triggered it (i.e. pre- vs post-event triggering).
For me, the difficulty with these two attributes isn't comprehension; it's memorization. I find myself looking this stuff up over and over again. So, to make it easier to remember, I mocked up the following diagram. Hopefully it has some use for you as well.
Note, the graphic above was corrected on 4/25/15:
- OnWindowOpen was green (pre), now it's red (post)
- OnWindowClose was red (post), now it's green (pre)
- OnGestureTap was shown after OnLayoutSizeChange, now it's after OnLayoutKeystroke
- OnPanelSwitch was shown after OnObjectExit, now it's after OnGestureTap
Breaking this graphic down a bit...
There is a method to the order in which triggers fire:
- First, you have the entering into the interface elements, which happens in the following order: file, window, layout, mode, view, record, object.
- Next you have the interacting with the objects that have been laid out; e.g. a user types something, a script makes a field active, etc. Each of these script triggers deals with objects (except for OnLayoutSizeChange, OnGestureTap and OnLayoutKeystroke).
- You complete ehe "transaction" with the leaving of the interface elements, which happens in reverse order: object, record, view, mode, layout, window, file.
I've marked the post-event actions in red to connote a sort of warning as FileMaker does not allow us to cancel these triggering events.
A comment on the differences between FileMaker 12 and 13:
FileMaker 13 introduced two brand new triggers and a change to one of the existing triggers:
- OnLayoutSizeChange - mostly targeted towards iOS, but also fires when a window is resized in Pro, including as a result of showing or hiding the status toolbar
- OnGestureTap - iOS only; remember that it also fires even when you tap a button or tap to enter into a field
- OnPanelSwitch - replaces OnTabSwitch to account for the new slide control (slide panels are akin to tab panels with respect to the OnPanelSwitch trigger); also note the change in firing order (OnTabSwitch used to be after OnLayoutKeystroke)
Wim Decorte's Script Triggers PDF Reference and Test File
Update May 2015:
On the face of it, script triggers are fairly straightforward. But there are nuances and non-obvious considerations to each one. Wim's color-coded PDF reference provides notes that highlight these subtle variations.
For instance, did you know that the OnLayoutSizeChange trigger won't run in Preview mode? Here's another exampe: if you drag & drop data into an inactive field, the OnObjectModify trigger will not fire for that field even though its content will have been modified.
The test file demonstrates the firing order and behavior for each trigger. Open it in Pro, Go, and in your web browser (via WebDirect) to learn how triggers behave in different clients. The layout contains every conceivable type of object, so that no stone is left unturned.
Since all possible events are configured, the tool is great to see the exact sequence of events on any number of actions such as moving between fields, moving between records, switching between tabs or panels, opening up a pop-up, etc.