Modal Popovers + Magic Date Value Lists

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.

Modal Popover

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.

2016-10-23_112805

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.

2016-10-24_103244

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).

2016-10-24_102439

The first two triggers include a parameter, like so:

2016-10-24_111514

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.

2016-10-24_111741

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…

2016-10-28_175403

So I created a VirtualValueList table and defined the highlighted field…

2016-10-24_233350

…connected VirtualValueList to Settings, like so…

2016-10-25_001352

…based the value list on the preceding…

2016-10-25_001821

…ignored this dialog…

2016-10-25_002401

…attached the VL to the appropriate field and formatted it as a popup menu…

2016-10-25_021450

…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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s