Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Interapplication Communication /
Chapter 9 - Recording Apple Events / What to Record


Recording Typing

In general, to record typing your application should send itself a Set Data event that sets the contents of the selection. The data should be unstyled text. When your application handles the Set Data event, it should apply the styles that prevail at the insertion point. If your application supports styled text, you need to decide how to apply styles to new text and how to record style changes to selected text. Follow these general guidelines for recording typing:

The rest of this section provides examples of how to apply these guidelines.

Suppose the user sets an insertion point and then types something. Your application should use the style, font, size, and other characteristics of the text just before the insertion point for the new text, and it should record only the new characters inserted. For example, to place the insertion point after word 30 and insert the text "This is the new text," your application can send a Select event followed by a Set Data event:

Notice that the Select event in this example causes your application to set its pSelection property (the current selection) to the location specified by the object specifier record in the direct parameter--that is, after word 30. The Set Data event then sets the contents of the selection to a text string. The pContents property specified by the object specifier record in the direct parameter of the Set Data event represents the contents of the selection, and the text string in the keyAEData parameter is the text to which the selection's contents is to be set.

At this stage, the insertion point is after word 35--the last word added by typing. If the user now selects one of the new words, say word 34, and changes the style to boldface and the font to Helvetica\xC6, send a Select event and two Set Data events to record the action:

After these three events are sent, word 34 remains selected. Thus, subsequent user actions upon the same selection do not require your application to send an additional event to set the selection. Your application should maintain the selection as long as the selected text is not replaced. If the user types or pastes new text into the selection, your application should place the insertion point after the new text.

Such a strategy might result in a series of events like these:


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996