Important: The information in this document is obsolete and should not be used for new development.
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.
- When the user sets an insertion point and types new text, use the styles defined for the text just before the insertion location.
- When a user selects text and changes its style, apply the changes to the selection.
- If a user types or pastes new text into a selection, place the insertion point after the new text.
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
- A Select event with this direct parameter places the insertion point after word 30:
Keyword Descriptor type Data keyDirectObject typeObjectSpecifier (see indented record) keyAEDesiredClass typeType cInsertionLoc keyAEContainer typeObjectSpecifier (see indented record) keyAEDesiredClass typeType cWord keyAEContainer typeNull No data keyAEKeyForm typeEnumerated formAbsolutePosition keyAEKeyData typeLongInteger 30 keyAEKeyForm typeEnumerated formRelativePosition keyAEKeyData typeEnumerated kAENext - A Set Data event (event class
kAECoreSuite
, event IDkAESetData
) with these parameters (keyDirectObject and keyAEData) sets the selection to the new text:
Keyword Descriptor type Data keyDirectObject typeObjectSpecifier (see indented record) keyAEDesiredClass typeType cProperty keyAEContainer typeObjectSpecifier (see indented record) keyAEDesiredClass typeType cProperty keyAEContainer typeNull No data keyAEKeyForm typeEnumerated formPropertyID keyAEKeyData typeLongInteger pSelection keyAEKeyForm typeEnumerated formPropertyID keyAEKeyData typeType pContents keyAEData typeChar "This is the new text"
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. ThepContents
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 thekeyAEData
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.
- A Select event with this direct parameter selects word 34:
Keyword Descriptor type Data keyDirectObject typeObjectSpecifier (see indented record) keyAEDesiredClass typeType cWord keyAEContainer typeNull No data keyAEKeyForm typeEnumerated formAbsolutePosition keyAEKeyData typeLongInteger 34 - A Set Data event with these parameters sets the style of the selection to boldface
:
Keyword Descriptor type Data keyDirectObject typeObjectSpecifier (see indented record) keyAEDesiredClass typeType cProperty keyAEContainer typeObjectSpecifier (see indented record) keyAEDesiredClass typeType cProperty keyAEContainer typeNull No data keyAEKeyForm typeEnumerated formPropertyID keyAEKeyData typeLongInteger pSelection keyAEKeyForm typeType formPropertyID keyAEKeyData typeType pTextStyles keyAEData typeEnumerated kAEBold - A Set Data event with these parameters sets the font of the selection to Helvetica:
Keyword Descriptor type Data keyDirectObject typeObjectSpecifier (see indented record) keyAEDesiredClass typeType cProperty keyAEContainer typeObjectSpecifier (see indented record) keyAEDesiredClass typeType cProperty keyAEContainer typeNull No data keyAEKeyForm typeEnumerated formPropertyID keyAEKeyData typeLongInteger pSelection keyAEKeyForm typeEnumerated formPropertyID keyAEKeyData typeType pFont keyAEData typeChar "Helvetica"
Such a strategy might result in a series of events like these:
- A Set Data event with these parameters sets the contents of a selection to "More new text":
Keyword Descriptor type Data keyDirectObject typeObjectSpecifier (see indented record) keyAEDesiredClass typeType cProperty keyAEContainer typeObjectSpecifier (see indented record) keyAEDesiredClass typeType cProperty keyAEContainer typeNull No data keyAEKeyForm typeEnumerated formPropertyID keyAEKeyData typeLongInteger pSelection keyAEKeyForm typeEnumerated formPropertyID keyAEKeyData typeType pContents keyAEData typeChar "More new text" - Two Paste events paste the contents of the Clipboard twice after the new text.