Over 46,000+ Business Solution Developers Find answers, ask questions, and connect with our community of business solutions developers, business owners and partners.
Script Triggers in FileMaker 13 – FileMaker Today
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.
Breaking this graphic down a bit…
There is a method to the order in which triggers fire:
First there is the entering into the interface elements, which happens in the following order: file, window, layout, mode, view, record, object.
Next is 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).
The “transaction” is completed 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, since 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)
Wim Decorte’s Script Triggers PDF Reference and Test File
(The FileMaker 12 version of these two files appeared in Kevin Frank’s post back in July 2012.)
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.