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


Moving the Selection During Recording

If recording is turned on and the user makes a selection, performs some action, and then makes a different selection, your application must make a decision: should it record the second selection in absolute terms or relative to the first selection? That is, should the corresponding AppleScript statement be

select insertion location before paragraph 5
or

select insertion location before paragraph after selection
Both statements may be appropriate under different conditions. But suppose that the user had selected paragraph 3 and now selects paragraph 12 or picture 3. Relative addressing doesn't make sense in these situations because the distance involved is too great or the unit is different. When you can't be sure of the user's intent, you should use absolute addressing. You can safely use relative addressing only when the user moves the selection or insertion point by only one unit, as with the arrow keys.

Even the use of the arrow keys does not guarantee that you can use relative addressing. For example, suppose that the user has selected cell 5 of row 2 in a spreadsheet and then presses the Left Arrow key three times. In this case, it is best to send Apple events equivalent to the statement

select cell 3 of row 2
rather than the statements

select the cell before selection
select the cell before selection
select the cell before selection
Using relative addressing in certain circumstances may minimize the amount of editing that the user must do after recording a script. However, recordable applications are not required to use relative addressing.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996