Today we’ll be exploring the concept of using popovers as modal dialogs in FileMaker.

modal dialog is a type of control that forces the end user to look at something or take action before continuing. FileMaker has had this functionality with the advanced window styles for a while now, but many users find that opening a new window is frequently undesirable. This is especially true in Windows environments, where new windows don’t behave as nicely as they do on OS X.

A preferable control, one that’s been used on the Web for years, is to overlay your dialog box on top of the existing page. It feels less like you’re breaking from your existing context, and you don’t run into the issues that might occur when opening a completely new window. For the purposes of this exercise, we’ll focus on the styling to get things looking good!

The FileMaker modal dialog window style

*For additional information on how to avoid the common nuisance of popovers closing when clicking outside the box, David Thorp at Excelisys writes a very informative article.*

Building the popover

We’ll start by building out the popover itself. Select it from the status tool bar and draw the popover button on your layout.

Once you’ve got that on the layout, double clicking it in layout mode will bring up the popover itself.

This is what we’re primarily going to be editing. Popovers have an interesting property in that they can be larger than the layout itself, and FileMaker will go with it and have it fill out the layout completely.

Resizing the popover & adjusting the fill color

That’s exactly what we’ll do here to get our desired effect. Select the popover and set its width and height to be greater than the total width and height of the entire layout.

This works great until you resize the window. You’ll notice that the popover doesn’t continue to fill the window, and that’s expected. Right now, the popover is locked to the left and top edges of the window for auto-sizing purposes—this means it won’t resize once we resize the window. We actually need to lock it to all four edges of the window.

Note that I also opted not to show a title on the popover, as that would interfere with our effect. You can get this dialog by double clicking on the popover.

     

 

 

 

 

 

 

 

 

 

 

Now we’ll change the fill color of this popover to a solid black with an opacity level of 29 percent. This will give us the transparent background we’re looking for.

Adding content

Next up is the content. There’s a couple of ways to do this. I’ll touch on the first one, but note that it’s not the best way. It involves adding a substantial amount of padding (all sides) to the popover style, and then giving the Popover: Content style a white (or other color) fill.

This achieves the effect of a transparent background with a place to put your content but it doesn’t deal well with varying window sizes. At a certain point, the interior of the popover becomes scrollable which may confuse some users. It’s probably best to stay away from this one unless you can guarantee a window size.

The preferable and simpler method is to place a rectangle right on top of the popover panel, set its fill color to whatever you want and enable all four edges for auto-sizing just as you had done for the popover itself.

From there, you can add any content you want within that rectangle. Just make sure to pay attention to the auto-sizing settings of those objects.

Removing the animation

One final item to consider is the animation that occurs when you open this dialog. The default behavior of a popover is to use a neat little animation when it’s opened. For most cases of popovers, this can be a really nice effect, but it can be a little distracting in this scenario. Luckily, FileMaker gives us a way to programmatically open popovers and disable the animation feature.

To disable the feature, select the popover and give it a name (shown left). In this case, we’ll keep it generic and call it modalPopover, but you’ll probably want to be a little more specific in your real world usage.

Creating the script

Giving it a name allows us to refer to this specific popover directly within a script. From here, we’ll create this script:

Then, we create a new button to call that script (below).

 

But now we have two separate ways to get to the same place with slightly different behaviors. Not good, right? We can fix this pretty easily with the Hide object when feature. Select your popover button, switch over to the data tab of your inspector and enter a 1 under the Hide object when section. You’ll also want to enable Apply in Find mode.

That will allow you to easily access the popover in layout mode, but prevent it from ever being shown to the end user. Despite being hidden, it’s still accessible through the button/script we created.

One last thing to note—you may notice there’s a small gap between the popover and the edge of the window. This is expected behavior. The solution to this involves creating rectangles with the same color/opacity as the popover, and placing them where those gaps are. You can then use the Hide object when feature to only show those gap fillers when the popover is active. This, combined with the methods outlined in the Excelisys article, will create a pretty seamless solution to this problem! As a bonus, I’ve included a demo on the layout ModalPopoverWithGapFill.

**Update**

This blog was updated on June 16, 2016 to adjust the format and supply the missing file link—so thanks, Robert Jackson, for pointing that out to me in your comment!

Download the sample file »The new sample file has also been updated to include Tanya Check’s awesome suggestion, as detailed in her comment below. Thank you for your input, Tanya!

Finally, I’d just like to thank you all for continuing to read my blog. Who knew it would still be generating so much interest a little over a year and a half later? I will be producing FileMaker blogs about once a month, so be sure to subscribe to our FileMaker Community blog if you’d like to receive emailed updates! 

5 comments

  1. Hi there. I followed your example and I love it. I’m including it in 2 different solutions this week. But I used a different very simple option to get around the small gap issue. And that was to add a spread of about 20 to the Outer Shadow of the PopOver. Using the same colours as the PopOver colour, you can’t see the white gap anymore. If you actually manage to click in that 2mm gap, the popover will close. But no one tries that… Just an idea. Cheers, Tanya.

    Posted by Tanya Check on February 12, 2016.

    • To have the popover *really* modal, you have to protect it against user pressing the escape key.

      While there are many ways to do it, I prefer attaching a OnLayoutKeystroke trigger, executing this script

      NoESC

      If [ Code(Get ( TriggerKeystroke )) = 27 ]
      Exit Script [ Result: 0 ]
      End If

      Posted by Siplus sA on June 20, 2016.

  2. Ryan – popovers seem straightforward but there is some useful nuances to take account of – thanks for sharing. A demo file is mentioned – couldn’t see the link.

    Tanya – comment is so useful! I really like this clever outer shadow spread idea to fill the small annoying gap at edge of window

    Posted by Robert Jackson on June 16, 2016.

    • Kyler Redmond

      Thanks for your help, Robert! If you read through the blog again, you will find the link at the end, along with an updated message from our author.

      Posted by Kyler Redmond on June 20, 2016.

  3. Popover as model dialog: In WebD, there does not seem to be any HIDE option that allows the popover button to execute from a GoToObject where the named object is within the popover. This works in FM, but fails in Chrome and Safari using WebD. No popover is triggered, IF the button is hidden.
    Conditionally formatting the field to not show, effectively hides the button, but does not eliminate inadvertent user interaction.

    Posted by Kirk Rheinlander on December 9, 2016.

Leave a comment