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
Control Manager Routines / Changing Control Settings and Display


DragControl

If you need to draw and move an outline of a control or its indicator (such as the scroll box of a scroll bar) while the user drags it, you can use the DragControl procedure.

PROCEDURE DragControl (theControl: ControlHandle; 
                       startPt: Point; 
                       limitRect: Rect; slopRect: Rect;
                       axis: Integer);
theControl
A handle to the control to drag.
startPt
The location of the cursor, expressed in the local coordinates of the control's window, at the time the user first presses the mouse button.
limitRect
A rectangle--which should normally coincide with or be contained in the window's content region--delimiting the area in which the user can drag the control's outline.
slopRect
A rectangle that allows some extra space for the user to move the mouse while still constraining the control within the rectangle specified in the limitRect parameter.
axis
The axis along which the user may drag the control's outline. The following list shows the constants you can use--and the values they represent--for constraining the motion along an axis:
         CONST
            noConstraint = 0; {no constraint}
            hAxisOnly    = 1; {drag along horizontal axis only}
            vAxisOnly    = 2; {drag along vertical axis only}
DESCRIPTION
The DragControl procedure moves a dotted outline of the control around the screen, following the movements of the cursor until the user releases the mouse button. When the user releases the mouse button, DragControl calls MoveControl. In turn, MoveControl moves the control to the location to which the user dragged it.

The TrackControl function automatically uses the DragControl procedure as appropriate; when you use TrackControl, you don't need to call DragControl.

The startPt, limitRect, slopRect, and axis parameters have the same meaning as for the Window Manager function DragGrayRgn.

SPECIAL CONSIDERATIONS
Before tracking the cursor, DragControl calls the control definition function. If you define your own control definition function, you can specify custom dragging behavior.

ASSEMBLY-LANGUAGE INFORMATION
Like TrackControl, DragControl invokes the Window Manager function DragGrayRgn, so you can use the global variables DragHook and DragPattern.

SEE ALSO
For information about creating your own control definition functions, see "Defining Your Own Control Definition Function" beginning on page 5-102. See the description of the DragGrayRgn function in the chapter "Window Manager" in this book for a more complete discussion of the startPt, limitRect, slopRect, and axis parameters, which are used identically in the DragControl function.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996