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: Macintosh Toolbox Essentials /
Chapter 5 - Control Manager / Control Manager Reference
Application-Defined Routines / Defining Your Own Action Procedures


MyAction

Here's how to declare an action procedure for a control part other than an indicator if you were to name the procedure MyAction:

PROCEDURE MyAction (theControl: ControlHandle; partCode: Integer);
theControl
A handle to the control in which the mouse-down event occurred.
partCode
When the cursor is still in the control part where mouse-down event first occurred, this parameter contains that control's part code. When the
user drags the cursor outside the original control part, this parameter contains 0.
DESCRIPTION
Your procedure can perform any action appropriate for the control part. For example, when a mouse-down event occurs in a scroll arrow or gray area of a scroll bar, TrackControl calls your action procedure and passes it the part code and a handle
to the scroll bar
. Your action procedure should examine the part code to determine
the part of the control in which the mouse-down event occurred. Your action
procedure should then scroll up or down a line or page as appropriate and then call
the SetControlValue procedure to change the control's setting and redraw the
scroll box.

ASSEMBLY-LANGUAGE INFORMATION
If you store a pointer to a procedure in the global variable DragHook, your procedure is called repeatedly (with no parameters) as long as the user holds down the mouse button. The TrackControl function invokes the Window Manager function DragGrayRgn, which calls the DragHook procedure. The DragGrayRgn function uses the pattern stored in the global variable DragPattern for the dragged outline of the indicator.

SEE ALSO
Listing 5-19 on page 5-53 illustrates a pair of action procedures for scrolling through a text document. As an alternative to passing a pointer to your action procedure in a parameter to TrackControl, you can use the SetControlAction procedure to
store a pointer to the action procedure in the contrlAction field in the control record. When you pass Pointer(-1) instead of a procedure pointer to TrackControl, TrackControl uses the action procedure pointed to in the control record.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996