|
|
|
Navigate: | My Mac Online | The Archives | March 1999 | FileMaker 101 - Part 12 | |
![]() |
|
![]() Part 12
My Mac Magazine manavesh@mymac.com
Layout with Global Containers This month we're going to have some fun. We're going to look at how to use global container fields to create layout effects, such as alternating background color and highlighting. It's difficult to look at a full-screen list view of rows (records) when they're all the same color. You can leave darker spaces or stick lines beneath each record to separate them. But my experience is that it not only takes up a little extra room, but is actually distracting, making it harder to focus on the data. It also violates a general rule of layout that I've discovered, which is, "Show the minimum of layout objects that are needed to distinctly display the relevant data." Something is needed to "distinctly" show the data; just plopping it on a background isn't enough. But too many layout elements can be worse than too few. Every line draws some attention, so make sure it is needed. You can also lessen the confusion of interfaces by reducing contrasts, e.g., using a light gray next to a slightly darker one rather than too much black and white. Notice also that you only want the "relevant" data. If there is too much information it also becomes difficult to quickly see what you need.
Alternating Row Background for Lists It uses a global container field to hold the alternate color(s) and a calculation field to display it. Remember that a global field is available to all records. So all that is needed is a calculation that is true for every other record.
Layout steps Give it a line but make the fill transparent. Choose Graphics from the Format Menu, then check Reduce or Enlarge image and uncheck the Proportional box. This will allow whatever you paste in--regardless of its size--to completely fill the box. Select the Rectangle tool over in the Tool Bar and draw a box on the layout. Fill it with white. Copy it. Now switch to Browse Mode, click RowBack g and Paste. It should fill with white. (Having to copy in Layout, then paste in Browse is annoying, but unavoidable.)
Calculation The Mod function divides by a number (2 in this case), then returns the remainder. This returns 1 for the 1st record, 0 for the 2nd, 1 for the 3rd, 0 for the 4th, etc. Since Status(CurrentRecordNumber) is recalculated for every found set, it will always be this pattern no matter what records are showing.
List View Layout Steps A tip (from Beverly Voth) makes it fill the Body perfectly. Use the Field Borders dialog, Format Menu (Cmd-Opt-B) to set the border lines on for all sides. Then in the line width set it to none. This allows the background color to completely fill the size you've set. Choose Graphic from the Format Menu, check Reduce or Enlarge, no Proportional for RowBack c.
Send RowBack c to the back of the layout (Cmd-Shft-Opt-J). Choose the lightest gray for the Body color (use the Body tab). Switch to Browse Mode and voila, alternating row backgrounds. Set all your fields on the row to be transparent. Borders are optional. I find that the top and bottom ones aren't needed. A clean way to show off columns of right-aligned numbers is to set them to have only a left border, with a medium gray line color. Put a pixel or two between fields. It looks clear but uncrowded.
Easy Row Outliner
Highlight with Color Define another global field, RowBox g, type Container. Go to the Graphics layout, Layout mode, and put it on the layout. This time stretch it to about the same size as you'd want it. Set it to Reduce or Enlarge, just to be safe. Now draw a another box with the Rectangle tool, the same size as RowBox g. This time set the fill to transparent and the line color on and colored. Copy the box. Switch to Browse Mode and Paste it into RowBox g. It should look the same.
Define a new calculation field, RowBox c, with a container result.
If ["Serial ID <> Serial ID g"] Put RowBox c on the List View layout, on top of the fields. The easiest way is to Option Shift-Drag RowBack c a little, then double-click it and change it to RowBox c (since they're the same height). Hit Cmd-Shft-Opt-F to bring it to the front. I like to make RowBox c a little narrower than Rowback c, so I can select either.
If the fields below are not editable, you can attach the script directly to RowBox c (Format Menu, Button). Then just clicking on a row will highlight it.
But if they are editable, you'll need a small button to trigger the highlight. It can be in the box, on the left. Or the highlight could be the result of any navigational script, by tagging the above script at the end.
Background Highlight
Get it by changing the RowBox c calculation a little. RowBack Hc =
Conditional Background Highlight
Option-Drag RowBack c to make this new field, just above it on the layout. This will show the darker shade of gray on every third record.
To be efficient, you could put the calculations together, so that you only needed one calculation field instead of two to do both backgrounds.
RowBack c= This is known as a "nested" calculation. Notice that the Mod, 3 argument goes first, so it can override and give us a different color. Also, the default is written last, on a line by itself. This not only makes it easier to read, but easier to count those darn parentheses. Two If's requires two parentheses at the end. You could even put each argument and result on a different line, as the calculation dialog ignores typed carriage returns.
Fenton Jones
FileMaker 101 - Previous Columns
|
|
Copyright ©1995-2000 My Mac Productions, All Rights Reserved |