Today we’re going to explore a couple ideas that were glossed over in last month’s article on the CustomList custom function…
- implementing a “modal” popover
- using a “magic” value list to display a properly sorted list of dates
…and you can download a copy of today’s demo file, Date Filtration, if you are so inclined.
One of the most useful FileMaker features introduced in the last few years is the popover (if you aren’t familiar with them, Howard Schlossberg’s presentation provides an excellent introduction). In the standard implementation, you click once to display the popover, and then click anywhere outside the popover to dismiss it.
Sometimes, though, you want the popover to remain on screen, with all other system interaction disabled, until the user has completed a task — for example, made a valid selection from a popup menu.
In other words, you want the popover to be modal, and FileMaker popovers are not modal by default. Fortunately, as David Thorpe has convincingly demonstrated, it’s not difficult to make popovers behave modally, and my approach is essentially the same as David’s with keystroke trapping and a couple logical validation tests added for good measure.
Once the modal popover has been activated…
- it can only be closed by pressing the Cancel or OK buttons
- hitting Esc is the same as pressing Cancel
- all other keystrokes will be ignored
- user must make a valid selection from the popup menu before the OK button will dismiss the popover
…and this is accomplished with the help of a script and some script triggers (note: the triggers are attached to the popover object itself, not to the button that invokes the popover).
The first two triggers include a parameter, like so:
Also, as you might expect, the OK and Cancel buttons call the “valid mondays popover” script as well, with parameters matching the button name (“ok” or “cancel”).
And here is the script.
Note: while modal popovers share many similarities with modal dialogs, one crucial difference is that a modal dialog prevents the user from interacting with any background window in your app, whereas a modal popover does the same for the current window only.
Magic Date Value List
Long time readers of this blog may recall Andries Heylen’s Magic Value List demo from 2012. In a nutshell, the technique allows you to base a value list on the contents of an unstored text field, and my initial plan was to use that approach to construct the popup menu of “valid” Mondays we saw in last month’s article.
The problem with that plan was that the technique relied on a text field, which meant that date values sorted as if they were text, but I needed them to appear in chronological order, in other words…
So I created a VirtualValueList table and defined the highlighted field…
…connected VirtualValueList to Settings, like so…
…based the value list on the preceding…
…ignored this dialog…
…attached the VL to the appropriate field and formatted it as a popup menu…
…and, voila, problem solved.
For more on this, as well as even more elaborate value list trickery, see Jeremy Bante’s Virtual Value List module at modularfilemaker.org.