Workbench User Guide : Generating Frames from Predefined Templates : The font_dialog Template : How You Can Call a Font Dialog Frame
 
Share this page          
How You Can Call a Font Dialog Frame
To open the Font dialog frame in your application, you must add a callframe statement to the script of the frame in which you want to change the font. In your callframe statement, you can optionally pass by reference the entry field to be changed. Otherwise, the dialog automatically searches for any active entry field in the parent frame.
You would perform the following steps:
1. Open the dialog by clicking Format, Font on the floating menu bar.
2. Specify “textfield” as the field to change.
3. On the frame from which you will be calling the Font dialog, create a menu button called “Font” on a pull-down menu called “Format”.
4. Create an entry field called “textfield.”
5. Add the event block for the Font menu item:
on click menu.format.font =
{
     callframe My_Font_Dialog(fontfield =
               field(textfield))
               with parentframe = CurFrame;
}
When the dialog is created, its font settings and the Sample display box reflect the current font attributes of the active (selected) form field. You can override this behavior by passing a reference to any form field containing text when the Font dialog is opened. The Font dialog's frame script provides instructions and code samples that you can add to your parent frame to automatically track the currently selected field.
To use the My_Font_Dialog, you must provide an event handler in a parent frame script to open the dialog when required:
openframe My_Font_Dialog (fontField = currently_selected_field)
                       with parentFrame = CurFrame;
The fontField parameter is optional. If you don not provide it, the template will try to find the current active field in the parent frame (the InputFocusField).
If you want the My_Font_Dialog to dynamically track the currently selected form field while the dialog is displayed, or if you want use it together with the Font_Bar toolbar segment, you must also include one or more of the event handlers described as follows.
To enable the Font dialog to track the currently selected field and display that field's font attributes, one or more of the following event handlers must be added to the parent frame's script (not the My_Font_Dialog script). Which event handlers to include depends on how much control you want to give the user.
To allow fonts to be set for entry fields only, include only the ChildEntry event handler. To also allow fonts to be set for other types of fields such as buttons, list fields, or trim, include one or both of the other handlers. If you only want to allow the font to be set for a particular field, no event handlers are needed. Instead, pass a reference to that field when the frame is created, as shown below:
openframe My_Font_Dialog (fontField = field (myField))
                       with parentFrame = CurFrame;
If you include event handlers to track the current field, you can add your own code to each of these handlers to perform application-specific processing.