Up   Previous   Next  

How MLTE Handles Text

When you use MLTE, your application does not need to contain all the code necessary to handle text. It can rely on MLTE and other Mac OS text technologies to do most of the grunt work for you. This section describes what tasks MLTE and other Mac OS text technologies handle for you, and what tasks your application needs to handle. If all your application needs to do is to display static text in a text box, you can skip this section. You need only to use one of two MLTE functions to display static text.

Note:
If you have ever used TextEdit in an application, be prepared to write fewer lines of code when you use MLTE. You'll see that MLTE handles many tasks that TextEdit did not handle.

MLTE supports standard text input from a keyboard. Once your application creates an MLTE document and associates the document with a window, anything your user types is displayed in the window. Your user may type on any keyboard layout using any script currently supported on the Mac OS. MLTE automatically supports inline input for Chinese, Japanese, Korean, other 2-byte scripts, and Unicode text.

When your application calls the MLTE initialization function TXNInitTextension , MLTE enables the Text Services Manager automatically. The Text Services Manager (TSM) is the part of the Mac OS that provides an environment for applications to use input methods that support text entry for languages such as Chinese, Japanese, and Korean.

If your application is Carbon-compliant, and it is running on a system that uses CarbonLib 1.1 or later, once you initialize MLTE, you do not need to do anything else to assure support for text input. Behind the scenes, MLTE calls TSM functions as needed, and TSM passes text input directly to an active MLTE document.

By default, MLTE stores text as Unicode. If a user enters text in an encoding other than Unicode, MLTE calls the appropriate Text Encoding Conversion (TEC) Manager functions to convert the text to Unicode. You do not need to call the TEC Manager functions directly.

MLTE uses Apple Type Services for Unicode Imaging (ATSUI) and QuickDraw functions to render and draw text. ATSUI handles complex scripts, supports bidirectional text, and implements a number of other advanced typographical features.

Your application does not need to call any ATSUI functions directly; MLTE does it for you. However, if you want to display and support editing text that uses advanced typographic features, such as ligatures or diphthongs, your application must supply ATSUI information to MLTE functions. For example, if you want MLTE to display text using a specific rare ligature, your application needs to pass an ATSUI constant to specify the ligature. ATSUI constants are defined in the reference documentation for ATSUI. The "MLTE Reference" indicates the functions for which ATSUI constants may be used.

MLTE has a variety of functions your application can use to make changes that affect an entire MLTE document or to change text attributes. For example, when a user changes the style of a selection, your application must call the appropriate MLTE function to set the style attributes for the selection.

Your application must provide the appropriate user feedback when the user takes any actions that affect what is displayed in any text-related menus, such as the Edit and Size menus. For example, if the user changes the font size for a selection, you application must call the appropriate Menu Manager function to display a checkmark next to the size item in the Size menu that applies to the selection. Or if the user selects text, your application must call the appropriate Menu Manager functions to activate the Cut and Copy items in the Edit menu.

There are a number of user actions that MLTE handles automatically for your application, such as highlighting selected text, dragging selected text, and moving the caret in response to arrow key presses.


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

Up   Previous   Next