Up   Previous   Next  

Creating a Font Menu Object

The TXNFontMenuObject structure is an opaque structure that MLTE uses to handle user interaction with the Font menu. You create a Font menu object by calling the TXNNewFontMenuObject function. You should create a font menu object at the same time you are preparing to display your menu bar.

When you call the TXNNewFontMenuObject function, you must provide the Font menu reference, the menu ID, and the menu ID at which hierarchical menus begin. By default, MLTE creates hierarchical menus.

The last part of Listing 3-3 shows how your application can create a Font menu object. If you want to display a checkmark next to the active font in the Font menu the first time a user opens the menu, you must call the function TXNPrepareFontMenu . However, you call that function right after you create a text object. See Listing 3-5.

Listing 3-3 Setting up the menu bar and creating a Font menu object
void MySetUpMenus (void) { Handle menuBar; // handle to menu bar OSStatus status; // status result from Gestalt // ---------------Setting Up the Menu Bar------------------------ // Call the Menu Manager function to read the menu bar. menuBar = GetNewMBar (rMenuBar); // Call the Menu Manager function to set the menu bar. SetMenuBar (menuBar); // Dispose of the menu bar handle. DisposeHandle (menuBar); // ---------------Creating a Font Menu Object------------------------ // Call the MLTE function to create a new Font menu object. status = TXNNewFontMenuObject (GetMenuHandle (mFont), mFont, kStartHierMenuID, &gTXNFontMenuObject); // If there is an error, call your own function to handle it. if (status != noErr) MyAlertUser (eNoFontMenuObject); // Call the Menu Manager function to display the menu bar. DrawMenuBar (); }

Copyright © 2001 Apple Computer, Inc. (Last Updated January 11, 2001)

Up   Previous   Next