Scripts give you complete control over the database windows on the screen. You can create new windows, close existing windows, bring any window to the front, and move or resize any window. (Why would a script need to monkey with someone's onscreen windows? See the box on Section 14.6.3 for some ideas.)
14.6.1. Creating Windows
To make a new window on the screen, you use the New Window script step. With this step selected in your script, you see a Specify button in ScriptMaker's Script Step Options area. Clicking this button brings up the New Window Options dialog box, pictured in Figure 14-14.
The first boxWindow Namegives your script control over the name of the window. (Window name is something you can control only from a script. When you create the window from the Window menu, FileMaker assigns it a name for you.) You can also tell FileMaker how big the window should be (Height and Width), and where to put the window on the screen ("Distance from top" and "Distance from left").
Here are some tips on using the New Window Options dialog box:
14.6.2. Bringing a Window to the Front
In ScriptMaker parlance, you bring a window to the front by selecting it. As such, you use the Select Window script step. It has one option, which lets you specify a window by name, or select the current window, as shown in Figure 14-15. You also use the Select Window script step to show a hidden window and bring it to the front.
Note: Usually, the current window is already in the front, and you don't have to worry about this step. But when you run scripts that involve more than one database, as you'll learn in Chapter 15, you may need this step to bring forward the current window from another file.
|POWER USERS' CLINIC
Window Size and Position Calculations
The fact that you can set a new window's size and position using a calculation might seem a little strange. After all, do you really need a bigger window for someone named Bill? Do you want your windows in a different place on Thursdays?
In fact, though, you can do a lot of interesting things with window size and position calculations. FileMaker provides a handful of functions that let you find out about the size and position of the current window, and of the computer screen, and use that information in calculations:
By combining these functions in creative ways, you can make your scripts smart about how they size and position windows. For example, to make the new window appear slightly offset from the current window, use these settings:
Distance from top: Get ( WindowTop ) + 20
Distance from left: Get ( WindowLeft ) + 20
If you're paranoid, and you want to make sure the new window never hangs off the bottom of the screen, use this calculation for the "Distance from top" value:
Similarly, you can use the "Distance from left" value to make sure it doesn't hang off the screen's right edge. Just substitute WindowDesktopWidth, WindowWidth, and WindowLeft for WindowDesktopHeight, WindowHeight, and WindowTop.
14.6.3. Closing a Window
The Close Window script step has the same options as Select Window. You tell FileMaker which window to close: the current window, or one you specify by name.
14.6.4. Moving and Resizing Existing Windows
FileMaker has three ways to move and resize a window. You can opt for one of its canned window maneuvers or you can set the exact pixel size and location of the window just like you can with the New Window step. You can also hide the current window.
220.127.116.11. Adjust Window
The Adjust Window script step always operates on the current window, and it gives you just five simple choices:
Note: The Maximize options have slightly different behavior on Mac OS X and Windows. For example, when you maximize a window in Windows, and then select a different window, the second window also gets maximized. On Mac OS X, on the other hand, the second window keeps its original size. Also, a maximized window on Mac OS X fills as much of the screen as possible. On Windows, it fills FileMaker's outer application window, whatever size it may be, and there's no way to adjust the application window from a script.
18.104.22.168. Arrange All Windows
The Arrange All Windows script step is the equivalent of the four window arrangement options in the Window menu. You can choose to tile windows horizontally or vertically, or cascade them (see Section 22.214.171.124). On Mac OS X, you can also choose to bring all FileMaker windows to the front.
126.96.36.199. Move/Resize Window
For the ultimate in window control, call upon the Move/Resize Window script step. It can move and/or resize any window with pixel-perfect precision. Its Specify button shows the dialog box in Figure 14-16, where you can choose the window's size and position. As with New Window, you can leave any of the size or position values empty. When you do, FileMaker leaves that part of the window's size or position alone. For example, if you specify a new Width but leave Height blank, FileMaker makes the window wider or narrower, but its height doesn't change.
Note: Move/Resize Window also selects the window it acts on, which always brings the window to the front, and, if it's a hidden window, shows it.
14.6.5. Other Window-Related Script Steps
FileMaker has a handful of other window-related script steps, listed below. They come in handy if you need to exert more control over what your users see. (Not to imply that you're a control freak or anything.)
|POWER USERS' CLINIC
Controlling the Interface
If you want to pull out all the stops, you can use a combination of layouts, custom menus (Section 19.5.3), tooltips (Section 19.4) and scripting to almost completely take over control of your database. You can hide and lock the status area, then give the user buttons to go to the next, previous, first, and last records. You can make it so that when you click a Customer on the list layout, a new Detail window pops up named after that particular customer. You can even make your script so smart that it selects an existing detail window for the customer if one exists, and makes a new one otherwise.
In this way, you give the user the impression that each customer has his own window, and you make comparing customers side by side a breeze.
This kind of high-level window management takes a fair amount of work, so most people stick with the normal every-layout-in-one-window approach and let the user create windows as needed. Which approach you use depends entirely on how much time you want to spend writing scripts and how important the multiple-window interface is to you.
Part I: Introduction to FileMaker Pro
Your First Database
Organizing and Editing Records
Building a New Database
Part II: Layout Basics
Advanced Layouts and Reports
Part III: Multiple Tables and Relationships
Multiple Tables and Relationships
Advanced Relationship Techniques
Part IV: Calculations
Introduction to Calculations
Calculations and Data Types
Part V: Scripting
Part VI: Security and Integration
Exporting and Importing
Sharing Your Database
Part VII: Appendixes
Appendix A. Getting Help